I have a ContentPane created both declarative and programmatic.
Declarative :
<div dojoType="dijit.layout.ContentPane" id="abccp" href="abc.php?id=1" title="abc" onShow="do_abc()">
Programmatic
var obj_abc;
var abchref= "abc.php?id=1";
obj_abc = new dijit.layout.ContentPane({id:'abccp',title:'abc', href:abchref});
How can I call do_abc() in the programmatic ex
To be technically equivalent to your first example, you'd just include onShow: do_abc
within the arguments object passed to ContentPane's constructor. (Note no parentheses after do_abc
- we're interested in the function object itself, not the result of calling it!)
However, if you'd like to do it in a bit more extensible of a fashion, then I'd suggest doing it like this:
obj_abc = new dijit.layout.ContentPane(...);
obj_abc.connect(obj_abc, 'onShow', do_abc);
What this does is perform a hookup such that whenever obj_abc
's onShow
method is called, the do_abc
function will in turn be called (though in the context of obj_abc
, which presumably is what you want anyway). You also get the following added bonuses:
onShow
is a stub meant to be clobber-able)onShow
in this waydojo.connect
which you would have to tear down manually).For more information:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With