سؤال

How can I open a specific page in twitter bootstrap modal?

I have this page

NewUser.aspx

which contains a div and inherits the masterpage navigation menu.

I want to just open the div that contains the text boxes and buttons in the modal.

I've tried this

 <a data-target="#"  class="quick-btn" data-toggle="modal" href="/SystemSettings/NewUser.aspx" ></a>

JS

 $(document).ready(function() {
        $('[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(); });
            }
        });
    });
هل كانت مفيدة؟

المحلول

Try this instead:

Markup:

Create a placeholder DIV to show the modal content within, like this:

<a data-target="#myModal" class="quick-btn" data-toggle="modal" href="/SystemSettings/NewUser.aspx">Click Me</a>
<div class="modal hide fade" id="myModal">
</div>

JavaScript:

Add the .aspx page's content to an iframe, like this:

$(document).ready(function() {
    $('[data-toggle="modal"]').click(function(e) {
        e.preventDefault();
        var url = $(this).attr('href');
        $(".modal-body").html('<iframe width="100%" height="100%" frameborder="0" scrolling="no" allowtransparency="true" src="'+url+'"></iframe>')
    });
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top