JQuery + render partial + AJAX
Posted 07 July 2010 - 01:31 AM
I have success to used JQuery to get the value of renderPartial View. But the problem is arise when i was change the content of renderPartial for example using ajax request ( which is i was made in JQuery) to load some new value from Database.
My new content of renderPartial can't used the JQuery script which I was made first !!
I don't know why the result view of renderPartial as if they can't know about JQuery i was made manully first ??
Is there any solution or explanation about this problem ?? [ I'm new in PHP, Yii + JQuery + AJAX ] I'm very appreciate all.. Thanks before
Posted 07 July 2010 - 08:31 AM
Thanks zac.. but i still don't find a solution or summary exactly on those thread.
What i have aware probably are :
1. First , i call renderPartial in this form :
2. Second , I've tried second option to call renderPartial in this form :
I've looked the different which is the second send back jquery.js script too.
But two of both still not answer my problem. I have a JQuery script that i wrote
Yii::app()->clientScript->registerScript('browse', " JQuery Script ");
in the main page ( view ). In those JQuery script i did ajax call and then run controller to run renderPartial to update <div> region in my main page (view), the result is success ,BUT the result CAN'T worked to use JQuery i wrote before in main page ??
Anyone can give me explanation or anything to solve this problem.
Thanks a lot before.. I'm very appreciate all
Posted 07 July 2010 - 12:41 PM
I will tell about my real case in compact to give a graps :
1. I have a page said main page which is inisiate ajax call use JQuery ( where i did it in Yii::app()->clientScript->registerScript( ..... ).
2. I have : a. <input name="Name"> and CHtml::link() -> to call ajax request which is defined in ( no 1 ), SO when this link is clicked , it will request on controller to update region in no 2b below "PersonBrowser"
b. <div id="PersonBrowser"> region where i call renderPartial() to display a list of person in CGridView.
3. In ( no 1 ) location , i wrote JQuery statement to manipulate data in CGridView from (no 2b).
PROBLEMS ( I've made attemption ) :
1. In the first load of main page -> script in (no 3) can be used to manipulate data in CGridView. But after user clicked to link on (no 2a) , the result is displayed in region (no 2b) and script (no 3) can't be used again.
2. I SOLVED this problem with this ways:
I copy script in (no 3) which is used to manipulate data into [success] section on ajax call which is called when user clicked link (no 2a)
SO I have two of copy statement to manipulate data in GridView
BUT I still need an explanation for this case, and want to find better way to solve in elegant ways.
Sorry if my description confusing all you are, because my limitation in english.
I'm open from anything comment or critics about this post
Is there any suggestion, explanation, example, or summary ... I'm very appreciate it
Thanks a lot