How to prevent renderPartial render javascript at each request
AJAXduplicatejavascriptpreventrenderPartial
sorry, I just asked this question to Yii forum, but no comment
I have a index, calling JUiDialog, and use ajax to call another controller action result (HTML), which will show in that dialog
this action result has button with javascript actions, so I use renderPartial in the controller action to generate the HTML
but when User let the Dialog show again and again, this controller action has been request more and more times
then my index got a lot of same javascript code blocks
it’s funny, when User click the button in the dialog, the javascript code execute a lot
so they will see 3 times same alert, or even more
how to prevent javascript code pass each request? I just want to have 1 javascript code block at the first time
Possibly related Questions
-
I need help with dependent dropdown
July 1, 2012 By eldorado2768 4 Answers
-
Ajax Cform validation within renderPartial view
February 7, 2012 By TheDeveloper 4 Answers
-
CJuiDialog: referencing attribute
January 23, 2012 By msimaremare 2 Answers
TAGS
actioncreate ( x 2 )ACTIVERECORD ( x 4 )AJAX ( x 10 )ajaxSubmitButton ( x 4 )AR ( x 2 )cactivedataprovider ( x 2 )CActiveForm ( x 2 )cactiverecord ( x 2 )CGridView ( x 14 )CJuiAutoComplete ( x 3 )CJuiDialog ( x 8 )CListView ( x 8 )controller ( x 7 )Css ( x 2 )CStarRating ( x 2 )CTreeView ( x 2 )database ( x 5 )dialog ( x 2 )dropdownlist ( x 3 )EGMaps ( x 3 )extension ( x 3 )file ( x 2 )form ( x 6 )Giix ( x 2 )gridview ( x 2 )html ( x 2 )javascript ( x 3 )many_many ( x 4 )merge ( x 2 )model ( x 4 )Modules ( x 3 )multilanguage ( x 2 )php ( x 2 )redirect ( x 4 )Registration ( x 3 )relations ( x 5 )renderPartial ( x 8 )session ( x 2 )sorting ( x 3 )sql ( x 4 )url ( x 3 )urlManager ( x 3 )validation ( x 3 )yii ( x 11 )YiiAnswers Site ( x 4 )This website counts Questions and 429 Answers by 7508 registered users.

This is because you don’t remove your jQuery bind/live events.
Check http://www.yiiframework.com/wiki/216/update-delete-model-with-cjuidialog-works-in-cgridview/ and http://www.yiiframework.com/extension/eupdatedialog/ for examples how to fix this problem (yes both links are by me, and it looks like I removed the explanation about jQuery events so you will have to dig into source code), happy shoveling
By IFDattic · 555 days 5 hours 41 mins ago
Questions: 0 Accepted: 0 ( 0% ) | Reputation: 0
RenderPartial has two extra parameters : return and process output. The process output what it does is exactly that, process/renders the javascript.
For more advanced requirements:
By tonydspaniard · 553 days 17 hours 25 mins ago
Questions: 2 Accepted: 0 ( 0% ) | Reputation: 0
If you have set a bind event ON THE MAIN VIEW page not on the AJAX'ed contents then it shouldn't be that problem. But live (previous to jquery 1.7) binding normally provoques those type of issues.
By tonydspaniard · 553 days 17 hours 20 mins ago
thanks for ifdattic & tony, yeah I just check Yii’s ajaxButton action, it use “delegate” & “undelegate”, as I use ‘live’ but without die :p
my fault, thx your helps!
By taker.wu · 553 days 11 hours 48 mins ago
Questions: 2 Accepted: 0 ( 0% ) | Reputation: 0