| View previous topic :: View next topic |
| Author |
Message |
racecar789
Joined: 21 Sep 2006 Posts: 28
|
Posted: Fri Sep 21, 2007 7:47 pm Post subject: Attach tab onload event through API? |
|
|
Is there a way to attach an onload event attribute via API rather than html tab tags?
Was thinking something along these lines but not having any luck.
| Code: | var tabstrip = nitobi.loadComponent('tabstrip1'); //load strip
tabstrip.tab[1].onload.subscribe(someEventFunction); //attach onload function |
Thanks
Last edited by racecar789 on Sun Sep 23, 2007 6:14 pm; edited 1 time in total |
|
| Back to top |
|
 |
racecar789
Joined: 21 Sep 2006 Posts: 28
|
Posted: Sat Sep 22, 2007 7:53 pm Post subject: |
|
|
Including this patch works for now, pending a better way. Include Prototype library when using.
| Code: | //Execute function when tab document has fully loaded and all of its DOM elements are ready
//Example:
//1. get tab object: "var tab = tabstrip.getTabs().get(0);" //get first tab (or can get tab when creating it via API ex: "var tab = new nitobi.tabstrip.Tab()")
//2. run method: "tab.executeFunctionOnLoad(customFunction);" //will execute customFunction when tab's DOM is fully loaded
nitobi.tabstrip.Tab.prototype.executeFunctionOnLoad=function(customFunction)
{
//If page fully loaded, execute function
if (this.getContentLoaded())
{
customFunction();
}
else
{
//Else, wait for one second then try again
setTimeout(function(){this.executeFunctionOnLoad(customFunction)}.bind(this), 1000);
}
};
|
|
|
| Back to top |
|
 |
jake
Joined: 18 Oct 2007 Posts: 6
|
Posted: Sat Oct 20, 2007 5:16 am Post subject: |
|
|
Ohh you were so close!
You can try:
| Code: |
tab.onLoad.subscribe(myFunc);
|
(the only difference being the capital L)
Incidentally, no need to include Prototype to use bind. The nitobi toolkit includes a function called nitobi.lang.close() that does the same thing:
| Code: |
tab.onLoad.subscribe(nitobi.lang.close(myObj.myFunc, myObj));
|
"close" because the result is a "closure" |
|
| Back to top |
|
 |
racecar789
Joined: 21 Sep 2006 Posts: 28
|
Posted: Sat Oct 20, 2007 1:32 pm Post subject: |
|
|
| Thanks Jake, I'll use that from now on. |
|
| Back to top |
|
 |
|