【发布时间】:2017-08-31 15:56:50
【问题描述】:
我一直在寻找解决问题的方法,我看到了很多不同的方法来做到这一点,但没有一个对我有用。 我会把我的代码贴在这里,看看你是否能以某种方式帮助我。 我有一个可拖动的弹出窗口来显示注释。主屏幕上有一个项目列表,每次用户单击“查看”链接时,它都会打开带有此特定项目注释的弹出窗口。 一切正常。弹出窗口以正确的信息打开,我可以在屏幕上移动弹出窗口。那么我唯一的问题是: 一旦我关闭弹出窗口并打开一个新窗口,而不是将弹出窗口重置为原始位置,它会在我离开另一个窗口的位置打开。当用户关闭它时,我需要重置弹出窗口的位置。
这是我的 js:
require(['jquery'
, 'bootstrap'
, 'datepicker'
, 'typeahead'
, 'combobox'
, 'tagsinput'
], function($){
// DOM ready
$(function(){
$('.modal-dialog').draggable();
$('#noteModal').on('show.bs.modal', function(e) {
//get data-id attribute of the clicked element
var note = $(e.relatedTarget).data('note');
//populate the textbox
$(e.currentTarget).find('span[name="note"]').text(note);
});
});
});
这是我的 html 页面上的模式:
<!-- Modal to display the Note popup -->
<div class="modal" id="noteModal" tabindex="-1" role="dialog" aria-labelledby="noteModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="noteModalLabel">Note</h4>
</div>
<div class="modal-body">
<span name="note" id="note"></span>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
如何在每次用户关闭弹出窗口时重置它的位置?
谢谢!
【问题讨论】:
标签: javascript bootstrap-modal