How to avoid duplicate data when using ActiveForm on AJAX forms
When I am displaying an active form with AJAX, I see on firebug how certain files are downloaded constantly -ie. jquery.js, jquery.yiiactiveform.js. Anybody has any idea on how to solve that?
By tonydspaniard in Forms · Asked 618 days 22 hours 57 mins ago
Questions: 2 Accepted: 0 ( 0% ) | Reputation: 0
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 8890 registered users.

Problem is that on render the needed JS scripts are rendered too… To avoid this use
Note that in this case you need to manually include jquery.yiiactiveform.js in your main view.
By mdomba · 618 days 22 hours 48 mins ago
Questions: 1 Accepted: 0 ( 0% ) | Reputation: 0
That makes sense...
By admin · 618 days 22 hours 47 mins ago
This can get more complicated once you start using more components which uses more JS (and even CSS) files. I’ve found a solution which I’m quite happy with, which basically allows Yii to register all JS and CSS as per usual. The actual fix is a hook on jQuery’s ajax filtering, which removes any duplicate CSS and JS references. For up to date source, check http://www.eirikhoem.net/blog/2011/08/29/yii-framework-preventing-duplicate-jscss-includes-for-ajax-requests/
By eirikhm · 618 days 23 mins ago
Questions: 1 Accepted: 0 ( 0% ) | Reputation: 0
Your idea is really nice and it works... but still the duplicate script files (jquery, yiiactiveform, yiigridview, ...) are downloaded/sent to the browser. I personally like more the solution that does not even send that files as they are not needed.
By mdomba · 612 days 20 hours 41 mins ago
Another hint is to use renderPartial function if possible and set the fourth parameter to TRUE. This will process output and JS script tags are correctly inserted at appropriate places.
By kokomo · 612 days 20 hours 58 mins ago
Questions: 0 Accepted: 0 ( 0% ) | Reputation: 0
With the 4th parameter set to true, all output will be processed and that's why a duplicate jquery file will be downloaded... that is the problem discussed in this thread :)
By mdomba · 612 days 20 hours 44 mins ago