Jquery 引导远程模式删除javascript

Jquery 引导远程模式删除javascript,jquery,twitter-bootstrap,bootstrap-modal,Jquery,Twitter Bootstrap,Bootstrap Modal,我的引导应用程序中有modals。modals从远程数据源获取其内容。在这个模式中,我定义了一些javascript函数 我的问题是,当我关闭模式并再次打开它时,javascript代码会出现两次。这意味着单击事件将执行多次 是否有可能清除隐藏的modals javascript代码 我也用 $('body').on('hidden', '.modal', function () { $(this).removeData('modal'); }); 为了防止再次显示相同的内容,这里有一个示

我的引导应用程序中有modals。modals从远程数据源获取其内容。在这个模式中,我定义了一些javascript函数

我的问题是,当我关闭模式并再次打开它时,javascript代码会出现两次。这意味着单击事件将执行多次

是否有可能清除隐藏的modals javascript代码

我也用

$('body').on('hidden', '.modal', function () {
  $(this).removeData('modal');
});
为了防止再次显示相同的内容,这里有一个示例:

标记:

<button type="button" id="test">Launch modal</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog"></div>
</div>
这样,模态内容只加载一次。清空模式将是永久性的。

以下是一个示例:

标记:

<button type="button" id="test">Launch modal</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog"></div>
</div>

这样,模态内容只加载一次。清空模式将是永久性的。

可能您使用了jquery.append,因此重新单击时内容将重复。你能做一个JS提琴来了解这个情况吗?也许你使用了jquery.append,所以当重新点击时内容是重复的。你能做一把小提琴来了解情况吗?
<button type="button" data-toggle="modal" href="some href" data-target="#myModal">Launch modal</button>