-- HenryG <[email protected]> wrote
(on Wednesday, 04 February 2009, 04:05 AM -0800):
> I'm just starting out with Zend and Dojo and I have a quick question which I
> hope you can answer.
>
> I have built a tabbed dojo interface and some of the tabs contain dojo
> forms. I have a view helper which validates the dojo form onsubmit. The
> helper adds some javascript to head which connects up the submit button.
>
> The tabs are linked to an actions which use Context Switching to return an
> ajax response (I guess you'd call it lazy loading). Here's my problem, if
> I'm trying to lazy load a tab which contains a form then then the javascript
> for the head is not put in place. I cannot for the life of me figure out how
> this should be done. I've searched high and low before posting, so I really
> hope someone out there can help.
This is where digging into the Dojo documentation can help.
With dijit.layout.ContentPane, you can't return javascript; it simply
won't get executed. However, you *can* embed special script tags within
the content that the dojo parser will then parse and execute. As an
example, the following is something I've done:
<script type="dojo/method" event="onLoad">
dojo.connect(dijit.byId("submit"), "onclick", function(e){
/* actions go here... */
});
</script>
Note the "dojo/method" script type -- the parser recognizes various
dojo/* types and creates callbacks or binds events accordingly.
This can be added to your form via a custom decorator that renders
inside the ContentPane.
--
Matthew Weier O'Phinney
Software Architect | [email protected]
Zend Framework | http://framework.zend.com/