On Thursday 08 January 2009 12:22:31 Mustafa A. Hashmi wrote:
> I am in the process of switching our application to make use of dojo
> forms, however, am having some issues with forms which are rendered
> via xhr requests. In a nutshell:
>
> a) Layout is rendered and the index action renders a dojo form which
> works perfectly fine.
> b) After submitting the form, the user manually follows a link which
> calls a JS function and loads the required action template in a
> specified div.
> c) The loaded dojo form in the resulting div however doesn't seem to
> be 'dojo enabled'. The form does render, albeit without any styles or
> dijit functionality.

When using XHR to retrieve (X)HTML content that will be injected into
the DOM, you need to do two things:

  1) Any dojo modules that the new content uses must already be loaded
     (i.e., the dojo.require calls should already have occurred).
     Because of how Zend_Dojo works, anything aggregated in the dojo
     view helper will not be sent in the payload (unless you explicitly
     include it). Additionally, HTML content pulled by XHR ignores any
     <script>s attached -- which means even if you did return the dojo
     view helper payload, it wouldn't be executed. So your initial
     payload must have all the requisite dojo.require statements.

     For this reason, it's also best to turn on declarative markup for
     any XHR payloads -- since the programmatic elements will not be
     present. You can do this with the following:

        Zend_Dojo_View_Helper_Dojo::setUseDeclarative(true);

  2) You need to run the dojo parser over the returned content. If
     you're pulling the content into a ContentPane, you can do this by
     setting the "parseOnLoad" property of that pane to true. Otherwise,
     make sure you have the dojo.parser module loaded, and call:

        dojo.parser.parse(<dom node containing retrieved content>);


-- 
Matthew Weier O'Phinney
Software Architect       | matt...@zend.com
Zend Framework           | http://framework.zend.com/

Reply via email to