单击链接时保持Bootstrap Modal打开

时间:2022-04-09 00:30:30

I have an Ajax Modal and have a number of links within the modal, however when I click on the links it will reload the page not the content within the Modal. How can I keep the Modal open? The code I am using:

我有一个Ajax模型,并且在模态中有许多链接,但是当我点击链接时,它将重新加载页面而不是模态中的内容。如何保持Modal打开?我正在使用的代码:

  <div class="modal-header">
    <a class="close" data-dismiss="modal">&times;</a>
    <h3>Modal header 2</h3>
</div>
<div class="modal-body">

//content

<div class="modal-footer">
    <a class="btn btn-primary" onclick="$('.modal-body > form').submit();">Save Changes</a>
    <a class="btn" data-dismiss="modal">Close</a>
</div>


    $(document).ready(function() {

// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
    e.preventDefault();
    var url = $(this).attr('href');
    if (url.indexOf('#') == 0) {
        $(url).modal('open');
    } else {
        $.get(url, function(data) {
            $('<div class="modal hide fade">' + data + '</div>').modal();


        }).success(function() { $('input:text:visible:first').focus(); });
    }
});

});

1 个解决方案

#1


0  

Chose to use an iFrame plugin https://github.com/Nikku/jquery-bootstrap-scripting/pull/69

选择使用iFrame插件https://github.com/Nikku/jquery-bootstrap-scripting/pull/69

#1


0  

Chose to use an iFrame plugin https://github.com/Nikku/jquery-bootstrap-scripting/pull/69

选择使用iFrame插件https://github.com/Nikku/jquery-bootstrap-scripting/pull/69