我在Jquery
中有这段代码,我抓住GridView
索引的任意一行点击并重定向到另一页。
$('tbody > tr').click(function(){
pId= this.id;
window.location.href = urllink + '&pId=' + pId;
});
代码效果很好,但前提是我不在索引中使用搜索/过滤器。
在对索引中的任何列进行搜索后,单击不响应。为什么会这样?我该如何解决?
答案 0 :(得分:1)
您可以使用EVENT DELEGATION
来实现此目的。您可以将网格视图的父div定位为 Per the time stamps these errors are occurring in approximately one minute intervals. Please bear in mind that after a website has hard-crashed multiple times in close succession the Rapid Fail Protection feature of IIS will be triggered which monitors your site for hard-crashes, and if a certain number of errors occur in a certain amount of time then the site will be deactivated with a 503 error message in order to protect the stability of the server. If the site hard-errors more than 5 times in 5 minutes then the website is most likely malfunctioning, or exceeding its allocated resources in the shared environment, and will need to be reviewed by a developer to determine what aspect of the site is causing the application pool to crash.
This is an intentional configuration of the server to help ensure that no single user impacts other shared users by causing resource exhaustion issues on the server.
,如果您正在使用,那么您可以为pjax
容器分配ID,如
pjax
然后使用以下
<?php Pjax(['id'=>'my-container'])?>
或者您也可以使用 $(document).on('click','#my-container > table > tbody > tr',function(){
pId= this.id;
window.location.href = urllink + '&pId=' + pId;
});
事件替换从服务器加载的pjax:success
内容后触发,为了执行上述相同操作,请参阅DOCS
HTML
编辑:您可能需要根据$(document).on('pjax:success', function() {
$('#my-container > table > tbody > tr').on('click',function(){
pId= this.id;
window.location.href = urllink + '&pId=' + pId;
});
});
调整元素路径'#my-container > table > tbody > tr'
,如果表格不是HTML
则可能需要从>
移除#my-container > table
第一个孩子