0
功能的基本工作,但对于每个点击取消按钮,下一个按钮将添加点击数。例如,如果用户单击一次取消按钮,则下次点击具有不同ID的不同按钮时,萤火虫将显示包含表单(第2页)的页面以加载多次,而不是一次。这一切都是动态生成的,所以在父页面上可能会有多达10个div。发生的事情是:需要JQuery停止重复点击每个按钮
- 用户点击父页上的只读文本框
- 的onfocus清空从父页面的div和加载子页从子页面 3.form是只读的文本框现在空间
- 用户要么提交评论或取消
- 要么行动应该把只读文本框后面的 页面(到这一点,这所有的作品)
- 按另一个DIV时发表评论该网页只应升一次点击,而不是点击前一个按钮的次数。
在第一页,我有:
<head>
<script type="text/javascript">
$(document).ready(function(){
var ajaxInProgress = false;
$(function(){
if (ajaxInProgress) return;
$('.ce').focus(function(){
var cid = this.id;
$('#comfield'+cid).empty();
$('#comfield'+cid).load('content_comment.php?id=<%=intmemberid%>&cid=' + cid);
});
});
</script>
</head>
<body>
<div id="comform"
<div id="comfield2">
<input class="ce" id="2" type="text" value="Write a comment..." readonly="readonly" />
</div>
</div>
<div id="comdata2"></div>
<div id="comform"
<div id="comfield3">
<input class="ce" id="3" type="text" value="Write a comment..." readonly="readonly" />
</div>
</div>
<div id="comdata3"></div>
</body>
在2页我有
<script type="text/javascript">
$(document).ready(function() {
document.commentform2.comment.focus();
$("#cancelcomment2").click(function(){
$('#comfield2').empty();
$('#comfield2').html('<input class="ce" id="2" type="text" value="Write a comment..." readonly="readonly" />');
var ajaxInProgress = false;
$(function(){
$('.ce').focus(function(){
if (ajaxInProgress) return;
var cid = this.id;
$('#comfield'+cid).empty();
$('#comfield'+cid).load('content_comment.php?id=55&cid=' + cid);
});
});
});
$("#submitcomment").click(function(){
$('#formcomment').ajaxForm(function (data, textStatus){
$('#formcomment').clearForm();
$('#comfield2').empty();
$('#comfield2').html('<input class="ce" id="2" type="text" value="Write a comment..." readonly="readonly" />');
$('#comdata2').append(data).fadeIn(700);
var ajaxInProgress = false;
$(function(){
if (ajaxInProgress) return;
$('.ce').focus(function(){
var cid = this.id;
$('#comfield'+cid).empty();
$('#comfield'+cid).load('content_comment.php?id=55&cid=' + cid);
});
});
});
});
});
</script>
<form id="formcomment">
<textarea id="commenttext2>" name="comment" class="commentarea"></textarea>
<input type="submit" id="submitcomment" value="comment />
<button id="cancelcomment2">Cancel</button>
</form>
你忘了关闭'' – henryaaron 2012-03-09 22:12:31
哇!你甚至想要做什么?你可以做一个[jsfiddle](http ://www.jsfiddle.net)? – 2012-03-09 22:20:22