Open specific page in twitter bootstrap modal

旧街凉风 提交于 2019-12-13 09:30:03

问题


how can i open specific page in twitter bootstrap modal ?

i have this page

NewUser.aspx

wich contain div and inherit the masterpage navigation menu.

i want to just open the div that contain 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(); });
            }
        });
    });

回答1:


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>')
    });
});


来源:https://stackoverflow.com/questions/17954933/open-specific-page-in-twitter-bootstrap-modal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!