我在我的项目中使用了bootstrap的模式弹出窗口,并希望得到以下内容:
我正在寻找解决我的问题的方法,我看到了很多不同的方法来做到这一点,但没有一个对我有用。我将把我的代码粘贴到这里,看看你是否能以某种方式帮助我。我有一个可拖动的弹出窗口来显示注释。主屏幕上有一个项目列表,每次用户单击“查看”链接时,都会打开弹出窗口,其中包含该特定项目的注释。一切正常。弹出窗口将打开并显示正确的信息,我可以在屏幕上移动弹出窗口。那么我遇到的唯一问题是:一旦我关闭弹出窗口并打开一个新的弹出窗口,它不会将弹出窗口重置到原始位置,而是准确地打开我离开另一个弹出窗口的位置。当用户关闭弹出窗口时,我需要重置弹出窗口的位置。
这是我的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);
});
});
});
Run Code Online (Sandbox Code Playgroud)
这是我的 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> …Run Code Online (Sandbox Code Playgroud)