【发布时间】:2013-12-08 05:38:29
【问题描述】:
我的 bs3 模态中的 js 有一些问题 - 它不起作用。我正在使用 ajax 打开模式。
主页
<a href="/modals/comp_activate.php" data-target="#modal-ajax" data-toggle="modal"><i class="fa fa-plus-circle"></i> Activate this computer</a>';
<div class="modal fade" id="modal-ajax" tabindex="-1" role="basic" aria-hidden="true">
<img src="/assets/img/ajax-modal-loading.gif" alt="" class="loading">
</div>
<script src="/assets/scripts/custom/custom.js" type="text/javascript"></script>
<script>
jQuery(document).ready(function() {
Custom.init();
});
</script>
custom.js
var Custom = function () {
// private functions & variables
// external window links
var externalWindows = function() {
$("a[data-window='external']").on('click', function() {
window.open($(this).attr('href'));
return false;
});
}
// public functions
return {
//main function
init: function () {
//initialize something here
externalWindows(); // external window links
}
};
}();
模态页面中的链接
<a class="btn btn-primary" href="http://www.somesite.com/" data-window="external" onClick="$('#modal-ajax').modal('hide');"><i class="fa fa-shopping-cart"></i> Purchase Now</a>
所有这一切都是在浏览器的新窗口中打开带有data-window="external" 的任何链接。由于模式页面是使用 ajax 打开的,因此主页中的 js 在加载时不会“拾取”。我也可以在我的模态页面上添加该功能,但它会导致主页出现问题。
我可以在这里做什么?
【问题讨论】:
标签: javascript jquery ajax twitter-bootstrap