I am trying to use ajaxLink but am failing horribly.
I have a view which is getting rendered by the command renderPartial after an ajax call.
This new subview contains some links. I am trying to generate ajaxLinks with the following command:
echo CHtml::ajaxLink('This is an ajaxLink', array('site/showText'), array('update'=>'#content'));
I can see the link ‘This is an ajaxLink’ which also has an id assigned by yii (yt0).
However, I can not see any javascript added to my view file which would correspond with this generated id. Is this due to the fact that I am rendering the view partially?
There is no activity clicking on the ajaxLink - monitoring with firebug.
On an initial GET request the whole view is rendered and the JS is included. But that’s not true for rendered partials including javascript. Anyways, there is a way to tell Yii to process the rendered output of a view to also add the newly generated js by setting the fourth parameter of renderPartial to true:
Always assign your own ids to everything that uses JavaScript. The ids generated by Yii are easily duplicated when reloading partials which can cause weird stuff to happen (multiple ajax requests on one click etc.).
Some scripts may now be downloaded on every partial rendering action. Jquery for example. If that happens you can use
But i have a trouble here with this code.Well i have also done the same thing as you have guided.But What is my problem here is :
i have a Cgrid view Which i am showing with ajax call and with the help of renderPartial view
In this Cgrid view i have a CCheckBoxColumn.
my whole application is running with Ajax calls and renderPartial views.So, When call ajax for first time and load a renderPartial view with then perform a selection of checkboxes and hit a ajax Button for any other ajax call(Delete a multiple records) then it render a same Cgrid view with a updated results.
But then i try to select a checkboxes then only a main CheckBox(Which perform select All checkbox) is working like checked All or unchecked All.But child check boxes are not selectable individually.
I have a one more button which peform a Add record Ajax call which load a CActivForm to add a record.So,After Adding a record it again load that View which contain a Gird View with CCheckBoxColumn.So, when i try to select an individual checkbox then its not working.Only select All or unselect All action can be performed.
I know it is just an issue of redundancy of scripts.But your suggested solution is not working here.