SimpleModal 中的 JQuery 自动完成
我有一个简单的文本框,在 div 内带有 JQuery 自动完成功能,我在其中使用 SimpleModal 进行模式对话。 第一次调用模态对话时,自动完成功能运行良好。对话关闭后,它完全停止工作。有人知道这可能是由于什么造成的吗?
代码如下:
对话html:
<div id="simplemodal">
<div class="content">
<span class="label">国名</span>
@Html.TextBox("NewRegion", "")
</div>
<div class="commands">
<a>追加する</a>
<a class="simplemodal-close">キャンセル</a>
</div>
以及对话脚本
/*Show add region dialogue*/
function AddNewRegion(ProjectID) {
$('#simplemodal').modal({
closeHTML: 'simplemodal-close',
closeClass: 'simplemodal-close'
});
}
自动完成脚本
$(function () {
$('#NewRegion').autocomplete({ source: '/Regions/FindRegions' } );
});
我知道以前已经有人问过这个问题,但看起来这个问题从未得到解答。
I have a simple textbox with JQuery autocomplete inside a div on which I use SimpleModal to make a modal dialogue.
The first time the modal dialogue is called, the autocomplete works fine. After the dialogue is closed it completely stops working. Does anybody have any ideas what this could be due to?
Code is as below:
Dialogue html:
<div id="simplemodal">
<div class="content">
<span class="label">国名</span>
@Html.TextBox("NewRegion", "")
</div>
<div class="commands">
<a>追加する</a>
<a class="simplemodal-close">キャンセル</a>
</div>
and the script for the dialogue
/*Show add region dialogue*/
function AddNewRegion(ProjectID) {
$('#simplemodal').modal({
closeHTML: 'simplemodal-close',
closeClass: 'simplemodal-close'
});
}
The autocomplete script
$(function () {
$('#NewRegion').autocomplete({ source: '/Regions/FindRegions' } );
});
I know this has been asked before, but it looks like the question never got answered.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将您的两个 JS 代码示例合并为:
如果这不起作用,请告诉我。
Consolidate your two JS code samples into:
If that does not work, let me know.
下面的代码可能对你有帮助
The below code might help you
我也遇到过这个问题。可以通过在打开模态对话框时将
persist
选项设置为true
来解决。每次打开模式对话框时无需重新安装自动完成处理程序。
I've ran into this problem as well. It can be solved by setting the
persist
option totrue
when opening the modal dialog.No need to reinstall the autocomplete handler each time you open the modal dialog.