Chtml::ajaxlink Not Working In Gridview After Yiigridview('update')

Hi all,

I implemented a CGridView, the last column contains some links, e.g. a CHtml::ajaxLink().

These links work perfectly fine until I update the GridView via




After the JS call the ajaxLinks do not work anymore and I need to refresh the whole page to get them to work again.#

Any ideas how I could fix this issue?

Thank you!


The best solution is to not use the helper ajaxLink() and to write your custom jQuery to process your links…

I have same issue. I used CHtml::ajaxLink in CGridView one column.

Once I submit the search, it calls

$('.search-form form').submit(function(){

	$('#tool-inventory-grid').yiiGridView('update', {

		data: $(this).serialize()		


	return false;


The data in CGridView is updated, but the link is not.

I can see the link is source code is still as same as before updated.

The general problem is that when the cgridview is loaded the first time a jQuery function is called that attaches an event to the CHtml::ajaxLink(), but when yiiGridView(‘update’) updates the content of the gridview a new CHtml::ajaxLink() is displayed, but since the page is not reloaded the jQuery function to add the event is not triggered again. So there is now a link without an event to trigger.

Usually this is solved by using CGridView’s afterAjaxUpdate property that needs to call some jQuery function that does the same stuff that is done when the page is loaded.

Maurizio’s suggestion might fit your need better though.