【发布时间】:2012-07-09 16:43:08
【问题描述】:
我有一个表格,其中最后一个标签“td”调用了一个模态窗口。问题是只有在第一个模态窗口隐藏时才有效,页面重新加载,但对于其他模态窗口重新加载不起作用。
<a class="icon-remove-sign" id="exclusao" href="#modalExclude{{janela.campanha.id}}" data-toggle="modal" title="Excluir"></a>
// this generate the following urls:
// http://localhost:8000/display/detail/15/#modalExclude11
// http://localhost:8000/display/detail/15/#modalExclude12
// http://localhost:8000/display/detail/15/#modalExclude13
jQuery 代码:
$(function() {
$('#exclusao').click(function() {
var modal = $(this).attr('href');
console.log(modal); // show the href only for the first row --> #modalExclude11
// show modal
$(modal).modal({
show: false,
});
// clean message info in modal
$('div#messageExclude').html('');
// reload page when modal is hidden
$(modal).on('hidden', function() {
window.location.reload(true) // work only for the first row --> #modalExclude11
});
});
});
所有模式都正确显示,但只会使页面重新加载到表格的第一行。有谁知道可以是什么? 谢谢!
【问题讨论】:
-
呃,你为什么要在变量前面加上
$,尤其是那些不包含jQuery对象的? -
你能发布生成你的url的js代码吗?我怀疑因为它只适用于第一个,所以调用会再次生成 url 而不是拾取当前的……
-
我从代码中删除了“$”。图像显示两行,仅适用于第一行:i.imgur.com/z7bJI.png
-
我觉得你的问题有点抽象,你能发布一个工作示例的链接吗?
-
我有一个表格,在 td 我有一个模态,每一行都有一个模态窗口。问题是仅对第一个模态行进行重新加载工作。 #modalExclude11 是我的第一个模态,并且重新加载有效。但是从 #modalExclude12 开始,重新加载不起作用。
标签: jquery twitter-bootstrap modal-dialog