Yii Framework Forum: Ajax Functionality in $.load() Forms - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ajax Functionality in $.load() Forms Rate Topic: -----

#1 User is offline   queej 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 04-February 10

Posted 13 April 2010 - 09:53 AM

I love the CHtml::ajaxButton() functionality. Unfortunately, I can't get it to work in a complex form situation that I have.

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.
0

#2 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 13 April 2010 - 01:54 PM

You are using CHtml::ajaxButton inside one of the ajax loaded forms?
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#3 User is offline   queej 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 04-February 10

Posted 13 April 2010 - 02:07 PM

View PostVince., on 13 April 2010 - 01:54 PM, said:

You are using CHtml::ajaxButton inside one of the ajax loaded forms?


Yes. If I include() the form it works, but not if I load the form using jQuery. Waiting for document.ready() doesn't seem to affect it either way.
0

#4 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 647
  • Joined: 29-November 08
  • Location:Paris, France

Posted 13 April 2010 - 05:21 PM

Hi queej,
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 ...
ciao
8)
0

#5 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 13 April 2010 - 11:56 PM

Yes, That's why i asked the question if you add the submit button in the form loaded with ajax. You will need to either use live to bind the events or add the ajaxButton in the form without loading it via ajax.
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#6 User is offline   queej 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 04-February 10

Posted 14 April 2010 - 12:12 AM

Thanks to both of you! I figured it was something like that, but I wasn't familiar with the "live()" functionality. Will give it a try.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users