i am using CListView in my one of form. i used CHtml::link in one of column. and its html is like this
<a class="text-dark" value="31" href="javascript:void(0)" title="You received a new message">
and onclick of this link i called one javascript function
following function
$('a.text-dark').click(function()
{
var id = $(this).attr('value');
$.ajax({
type:'POST',
url:'<?php echo Yii::app()->createUrl('/mailbox/message/View') ?>/id/'+id,
success:function(data){
},
error:function(data){
alert('Your data has not been submitted..Please try again');
}
});
});
My main issue is on first page it works perfect. function is called perfectly. but whenever i click on next button from pagination and click on this link. function is not called. Except One page any page doesn't call function. What is problem?
the problem is because that is a new element and therefore the applied function should be applied again, or simple solution
$(document).on('click', 'a.text-dark', function(){
// do the job here
});
or add a function to your grid view and call it in after ajax update
'afterAjaxUpdate' => 'js:function(){ here do stuff }'