Reputation: 1671
I have a few jQuery click/hover events that attach to items in a list view, but when a user clicks to the next page and the results are loaded through ajax the events are no longer valid.
I can use live for some events, but since it is depreciated and inefficient for hover events I'm looking for a way to attach my events to new items when they are loaded... Is this possible?
Upvotes: 2
Views: 1277
Reputation: 552
You are looking for afterAjaxUpdate.
http://www.yiiframework.com/doc/api/1.1/CListView#afterAjaxUpdate-detail
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'afterAjaxUpdate'=>'functionCallBackName()',
));
Upvotes: 1
Reputation: 1815
You should be able to specify a callback on your $.ajax method:
$.ajax({
url: '/get/some/data',
...,
success: function(responseData, textStatus, jqXHR){
// Attach some events to the newly-loaded data or list view...
}
});
If you have any code examples of what you're working with, it would probably help flesh out a decent answer for you - not quite sure if this is what you were looking for or not.
Upvotes: 0