Ajax button live setting problem due to yii (jquery) update

Hi all,

I have a problem with a Ajax request.

I have a dialog which displays a searchform and underneath a result listing also with an CLinkPager.

The problem which I now have that the ajax submit button of the search form will do the ajax search request several times, when i clicked the paginator of the result before (for each click one request more for the search form) and afterwards do a search.

I replace the whole div (including search form+ result) on each ajax request and it seems thats due to an update from 1.4 to 1.5 (which also includes a jquery update) this behaviour is introduced.

My problem is that every ajaxSubmitButton client change code are done with "live"=true.


Therefore the code of the button will be in my case:

jQuery('body').delegate('#searchAuthorDialog','click',function(){jQuery.ajax({'success': function(data) {


                    },'type':'POST','url':'/yii/tracker/authors/author_dialog?render=search','cache':false,'data':jQuery(this).parents("form").serialize()});return false;});

#searchAuthorDialog is the id of the search button on that form.

The problem which I now have that this code also introduced on every paginator click and doesn’t overwrite the onclick event which was added the request before. So each onclick event is added to the next.

And I found no way to add my ajaxSubmitButton with clientChange $live parameter = false because then it would work like with the older jquery.

Because in CHtml::button client change is only called like this without live parameter: self::clientChange(‘click’,$htmlOptions);

How can this be done?

Mention: my resulting ajax request code hasn’t changed so this is not a bug of yii more a change of jquery how events are handled. I tested yii 1.5 with the jQuery JavaScript Library v1.4.2 which came with yii 1.4 and there everything works as normal.

So i guess there should be a way to disable this client change live setting for ajaxSubmit buttons to solve this issue.

Regards Horizons

Take a look at this discussion, maybe you are in this case.

This multiple submission is a know problem, I faced some time ago and I solved with the hack yo ufind in the post (now is also an extension)

I hope it helps.

This has nothing to do with "his own clientscript".

It is the problem of jquery which doesn’t overrule the on click event which is set with jQuery(‘body’).delegate(’#searchAuthorDialog’,‘click’,function(){… several times.

For the his own clientscript I do my rendering this way

 $this->renderPartial('//authors/dialog/authorDialog',array('model'=>$model,'search_model'=>$search_model),$return=false, $processOutput=false);




            echo $output;

Because I have programmed my application to only add custom js/jquery code to the CClientScript::POS_END in my ajax requests so I won’t get any jquery, juijqery js “reloading” request which i only do in CClientScript::POS_HEAD.

This I had done because I really wanted to speed up my ajax requests and doesn’t wanted the reloading of js files i have already registered as core script on each ajax request.

As i have written above I tested this with yii 1.4 and 1.5. It works perfectly in yii 1.4 and doesn’t work with yii 1.5.

If I use the jquery.min.js from yii 1.4 (jQuery v1.4.2) in yii 1.5 (jQuery v1.4.4) it also works perfectly.

If I change the $live parameter from true to false it also works with (jQuery v1.4.4) from yii 1.5.

The client change live parameter setting change would of course change my ajax resulting code from:




Thx for your help.

you can use my core fix to help you solve the problem

Jevent core fix

I have just created a small ‘demo’ for the blog code to show the problem.



Which will show a "userSelect" dialog in the post form. If you have now several user entries in you database you can search for them and use the CJuiSelectable to display the result below.

with yii 1.5 (jquery v1.4.4)

If you open the dialog and use the search you will get only one search request.

If you open the dialog and used the pagination from 1 to several times and search afterwards you will get multiple search ajax requests.

with v1.4.2 it works without any problem havent tested a jquery version beyond yet

@Igor Your Fix wouldn’t change this issue. Because the “live” parameter is also always set to true when using a ajaxSubmitButton without any possibility to set it to false.

I find a possible workaround but I am not really happy with it.

If I add $("body").undelegate("#searchUserDialog", "click"); before "$("#UserDialogSelectForm").html(data);" for each ajax html replace (button and pagination) it is working again with the newer jquery.

But I would find it better if I can just set this clientScript Live setting to false instead of true.

I just have also see, that it is not required that I click the pagination. The form itself with an ajaxsubmit button is enough. With every click on the submit which replaces/refreshes the whole form via ajax an extra on click event is registered for the button.

I just wonder why there is a the $live parameter in the clientChange function (defaults to true) which is never used or can’t even be changed for the ajaxsubmitbuttons etc.

Sure I can make my own class with changed code but I really thought this should be an option in the ajaxsubmitbutton itself.

BTW this issue seems to be introduced since jquery 1.4.3 with 1.4.2 my code works flawlessly.

That’s what I’m looking for right now

I have the same problem of seeing ajaxSubmitButton or ajaxButton keep sending ajax requests to actions.

After changing the core code to CHtml::clientChanged(… $live=false). The problem resolved.

Many thanks.

I solved this issue by changing the following:



$(’#".$this->id."-select-all-rows-link’).live(‘click’, function()…

Using the JQuery live function made things automatically rebind after a ajax call.

I have similar issue when implement add-to-cart as an ajax submit button, finally, i found if I add $(’#add_to_cart’).unbind(‘click’); before the ajax call function, it will work. here is it:



$(’#add_to_cart’).click(function () {


type: ‘post’,

url: ‘index.php?r=checkout/add2cart’,

dataType: ‘html’,

data: $(’#product :input’),

success: function (html) {

$(’#module_cart .middle’).html(html);