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.
CHtml::clientChange($event,&$htmlOptions,$live=true)
Therefore the code of the button will be in my case:
jQuery('body').delegate('#searchAuthorDialog','click',function(){jQuery.ajax({'success': function(data) {
$("#AuthorDialogSelectForm").html(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