问题
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