[英]How to make JQuery work after reload content?
I have a block(div) where i use to put information. 我有一个块(div),我用来放置信息。 I have a hidden form there?
我那里有隐藏表格吗? and it shows on click.
并在点击时显示。 But If I reload data in block(div) it works like link .
但是,如果我在block(div)中重新加载数据,它的工作原理类似于link。
This is my script: 这是我的脚本:
var comment_block ;
var show_comment_block;
var show;
$(function(){
$('A.reply').on('click',ShowCommentBlock);
});
function ShowCommentBlock(){
$(this).parent().next('.answer-form').slideToggle('slow');
return false;
}
And it is the code on my button: 这是我按钮上的代码:
<a class="reply" href="#comment<?php echo $comment['comment_id']?>">Ответить</a>
As i understand after content reload in block(div) i have to put this actions on new forms? 据我了解,在块(div)中重新加载内容后,我是否必须将此操作放在新表单上? I dont understand how to do that?
我不知道该怎么做? or maybe there is some other kind of solution.
也许还有其他解决方案。 Thanks.
谢谢。
You have to use delegation, eg: 您必须使用委派,例如:
$(document.body).on('click','A.reply', ShowCommentBlock);
A. Wolff 沃尔夫
Thank U! 感谢你!
也许将其更改为:
$('A.reply').live("click", ShowCommentBlock);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.