views:

449

answers:

1

I'm writing a form using Zend_Dojo_Form.

Everything goes fine, unless I dynamically insert elements into the form (using ajax, the user can add more elements by clicking a [+] button).

I managed to insert my new Zend_Dojo_Form_Element_FilteringSelect into the page, but the element isn't dojo-enabled (no auto-completion, or tundra styling).

I'm guessing dojo transforms existing form elements once the page is loaded the first time, and doesn't parse them again when a new node is added... But I can't find how to tell dojo there's new elements in town.

What I've tried:

  • Executing dojo.parser.parse(); or dojo.parser.parse('id_of_new_element'); after the insertion of a new element
  • Adding Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); in my Dojo_Form's init() method (as seen on nabble's forums)

My method for adding new elements is the one described by Jeremy Kendall.

I don't know if my problem comes from an incompatibility with Zend, Dojo, or if I'm missing something...

A: 

Here is an (old) link to an article about dojo.parser. It suggests what you already did: calling dojo.parser.parse(id_of_new_element). Without seeing your page it is difficult to pinpoint the error, but I could imagine that you'd also have to dojo.require() the appropriate modules for dojo to be able to enable the new form elements.

Gordon