[英]javascript function not woking after ajax request in CListView
i am using CListView widget (yii framework) like this. 我正在使用像这样的CListView小部件(yii框架)。
<?
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'template'=>"{items}\n{pager}",
));
?>
I have few button in "_view" and a process.js file where i have attached click event with buttons like this. 我在“ _view”中没有几个按钮,在一个process.js文件中,我已经将click事件附加到了这样的按钮上。
$(document).ready(function(){
$("a#beerButton").click(function(){
alert('clicked');
});
});
They are working fine in initial page display but after ajax update (Clistview pagination to view next page), no button is responding. 它们在初始页面显示中工作正常,但是在ajax更新(Clistview分页以查看下一页)之后,没有按钮响应。 What is causing the problem. 是什么引起问题。 Shall I have to include the js files again on update. 我必须在更新时再次包含js文件。
EDIT: 编辑:
on() event solved the problem :) Its working now. on()事件解决了问题:)现在可以正常工作。 Reference 参考
you should try this 你应该试试这个
$(document).ready(function(){
$("a#beerButton").live('click', function(){
alert('clicked');
});
});
检查您的js代码中的一些“)”和“}”不存在,请使用fire bug以避免此类问题...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.