Topic
2 replies Latest Post - ‏2012-07-12T19:02:55Z by SystemAdmin
ankurchaudhry
ankurchaudhry
1 Post
ACCEPTED ANSWER

Pinned topic How to catch Content Pane tab click event in dojo tab container builder??

‏2012-07-06T11:09:58Z |
I want to attach an html Event action(or simply run some script) on click of a particular content pane tab.
I tried using html action event builder and provided the page location as the content pane title but when i click the content pane tab nothing happens but it runs my script when i click inside the container area.

Please give suggestions on how to solve this problem!!
Thanks,
Ankur Chaudhry
Updated on 2012-07-12T19:02:55Z at 2012-07-12T19:02:55Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1569 Posts
    ACCEPTED ANSWER

    Re: How to catch Content Pane tab click event in dojo tab container builder??

    ‏2012-07-12T17:04:01Z  in response to ankurchaudhry
    I have been attempting the same idea: When the user clicks on the tab (which is currently not active), I want it to perform a task that could not be performed until the tab is displayed.

    I found in the dijit documentation to use the "watch()" function (http://dojotoolkit.org/reference-guide/1.7/dijit/layout/TabContainer.html#tabcontainer-events). However, I have not been able to get it to work for me. I have tried many things with no success.

    Here is my code:

    var appTabs = dijit.byId("appTabs"); // appTabs is the id of my div which is the dijit.layout.TabContainer
    appTabs.watch("selectedChild", function(name, oldVal, newVal){ // this line does not get an error
    console.log("selected child changed from ", oldVal, " to ", newVal); // but when I click a tab to activate it,
    }); // the function code here does not run.

    Sorry I don't have a functioning answer but maybe you will have success using the "watch" function. I am still fairly new to using dojo/dijit, which may explain my lack of success. I have also found little to nothing on the internet to help in using watch.
    • SystemAdmin
      SystemAdmin
      1569 Posts
      ACCEPTED ANSWER

      Re: How to catch Content Pane tab click event in dojo tab container builder??

      ‏2012-07-12T19:02:55Z  in response to SystemAdmin
      Ankur. In reply to my previous post, I may have an answer for you.

      I am using the watch function provided by Dojo. In my prior attempts to get it to work, I was "watching" for a child change of the tab container. I could not get that to work. I decided, instead, to monitor for a change to (or more correctly, the selection of) the tab I wanted to watch.

      Here is my code that catches when the previously unselected tab is selected (clicked on) with the mouse:

      var oneTab = dijit.byId("oneTab");
      oneTab.watch("selected", myFunction);

      function myFunction(name, oldVal, newVal) {
      console.log("selected child changed from ", oldVal, " to ", newVal);
      }

      In this simple code, the output to the console is: "selected child changed from false to true"

      I hope this helps you with what you were working on.