ajaxSubmitButton making multiple submissions

I have an ajaxSubmitButton in an AJAX lightbox (aka. modal window, using shadowbox if that matters) and I’m getting some strange behavior.

Basically if I submit the form, close the box, then open it again (which should be loaded fresh)it submits it twice when I press the submit button. In-fact it seems to do it proportional to how many times I have opened submitted the form already, for example if I have submitted the form 5 times it will call the controller 5 times.

It’s a real problem because this is forming the checkout of a cart and if I have made submitted the form (and say it doesn’t validate) then I submit it again, it places two orders. I can’t possibly see why this would be happening because everything is loaded fresh via AJAX.

Anyone have any ideas? I’m not really sure what code to post as I have no idea where this problem is originating from.

you are probably binding the event again in the ajax response

to solve it check if its an ajax response and if it is use render partial

if you need a layout do the following in your view:




if(Yii:;app()->request->isAjaxRequest)

$this->beginContent(''...");



Actually that makes sense, you see I didn’t use a renderPartial, rather I used render with a stripped down layout because otherwise the JavaScript required to make the ajaxSubmitButton work contained in the ajax rendered view work wouldn’t be returned. Is there any way I can use renderPartial but still have it return the JS that’s needed for the form?

What i do is not to use registerCoreScript helper

I do use CHtml::js

and CHtml::jsFile instead

but must exist a way to do it the way you said

Anyone ?

I think I worked it out, I just had to set the $processOutput parameter of renderPartial to True.

Hi,


I think I worked it out, I just had to set the $processOutput parameter of renderPartial to True.

Strange, because if I switch between $processOutput=true and $processOutput=false nothing changes.

How and where are you register/load the js code to load($.get) and open the form?

Which options from ajaxSubmitButton and CActiveWidget are used?

Are there any registerScript methods inside the action which renders the form-view?

best regards, rall0r