Jquery 对话框“缓存”多变的。如何避免呢?
我有一个对话框确认,必须将其重复用于 html 页面中的多个控件。
选择中的每次更改都会触发此对话框。
这是我的代码:
console.info("before:" + select[0].id);
dialog = $('#dialogReject').dialog(
{
autoOpen:false,
height:300,
width:400,
modal:true,
buttons:
{ "Ok":
function() {
console.info("after:" + select[0].id);
},
}
});
dialog.dialog('open');
所以,我有 2 个选择。我更改第一个,显示对话框。 before
& 中的id
after
是相等的。
我选择第二个,更改它并显示对话框。现在,在 before
中显示了正确的 id
,但在 after
中显示的是第一个选择的 id
。
如何避免这种情况呢?
I have a dialog confirmation that must be reused for several controls in a html page.
Each change in a select, fire this dialog.
This is my code:
console.info("before:" + select[0].id);
dialog = $('#dialogReject').dialog(
{
autoOpen:false,
height:300,
width:400,
modal:true,
buttons:
{ "Ok":
function() {
console.info("after:" + select[0].id);
},
}
});
dialog.dialog('open');
So, I have 2 selects. I change the first, show the dialog. The id
in before
& after
are equal.
I select the second, change it and show the dialog. Now in before
the correct id
is displayed but in after
is the id
of the first select.
How avoid this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我完全理解这个问题,但是如果您尝试更改对话框中的内容,您可能需要 .destroy() 在第一次调用之后。如果这没有帮助,请告诉我,希望我/其他人可以对此有更多了解。
编辑:该措辞含糊不清。我的意思是在关闭对话框时尝试调用
.destroy()
方法,并且“缓存”应该没有问题。Im not sure I entirely understand the question, but if you are trying to change content in a dialog you will probably need to .destroy() it after it was called the first time. Let me know if this isn't helpful and hopefully I/someone else can shed some more light on it.
Edit: That wording was vague. What I meant by that was try calling the
.destroy()
method when you close the dialog and you should have no problem with 'caching'.