我触发加载模式,然后我想用coffee / javascript处理内容 但加载的事件不起作用。我安装了最新的bootstrap版本3.2。
<a data-toggle="modal" href="/messages/new" data-target="#modal" data-remote="true">
我有以下可用的cofeescript(但如果加载模态内容的时间延迟,可能会在显示时失效)
$("#modal").on "shown.bs.modal", (e) ->
$(".typeahead-patient-search-box").typeahead
name: 'patients'
remote:
url: '../patients.json?query=%QUERY',
filter: (respData) ->
$(respData).each ->
this.value = this.full_name
this.tokens = $(this.full_name).text().split(/\s+/)
footer: "<a href='/patients/new'>Add New<a/>"
但将其更改为此(请注意我已将事件更改为已加载)
$("#modal").on "loaded.bs.modal", (e) ->
$(".typeahead-patient-search-box").typeahead
name: 'patients'
remote:
url: '../patients.json?query=%QUERY',
filter: (respData) ->
$(respData).each ->
this.value = this.full_name
this.tokens = $(this.full_name).text().split(/\s+/)
footer: "<a href='/patients/new'>Add New<a/>"
我已经隔离了相应的引导程序代码......
if (this.options.remote) {
this.$element
.find('.modal-content')
.load(this.options.remote, $.proxy(function () {
this.$element.trigger('loaded.bs.modal')
}, this))
}
}
使用断点我可以确认.find(&#39; .modal-content&#39;)运行但是。$ element.trigger(&#39; loaded.bs.modal&#39;)的断点是永远不会触发,我无法解决原因?!?
任何帮助将不胜感激