Ajax Functionality in $.load() Forms
Posted 13 April 2010 - 09:53 AM
The form is a member profile, comprising several different kinds of records/models. Each portion of the form is loaded using a jQuery $("#myform").load("my/url") type of call. For example, one section loads multiple address records using the MemberAddress model, while basic information is loaded using the Member model. Some of the loaded forms even render using other load() calls.
The result is that the Yii form code for the ajaxButton doesn't seem to get added in that situation. The code I see in Firebug for simple forms at the bottom of the page that sets up a jQuery click() function for the button does not appear in the complex form.
Any ideas on how to get it to work in this situation? Do I need to include some .js files in my loaded subforms?
Thanks in advance.
Posted 13 April 2010 - 02:07 PM
Posted 13 April 2010 - 05:21 PM
I'm not a JQuery expert but I think that if you ajax load a form that contains the CHtml::ajaxButton(), the button will not register its onSubmit handler function as the Document.onload event was already fired (when the container page loaded). JQuery provides the live() function to bind event and handler .. in live (that is, anytime). Maybe that can help you solving your problem ...
Posted 13 April 2010 - 11:56 PM