我有一个非常简单的jQuery-script,用于根据链接更改模式内容。代码:
$('#facebook-friends').on('hidden', function () {
$(this).removeData('modal');
});然后,我可以根据按钮控制要使用的内容:
<a href="facebook-frame.php" id="full-width" data-target="#facebook-friends" role="button" class="btn btn-primary" data-toggle="modal"><i class="icon-facebook"></i> Use Facebook</a>它工作得很完美!但是,我在这个facebook-frame.php文件中有链接,我希望所有操作都留在模式中,这样外部页面就不会重新加载。
我在facebook-frame.php中尝试过这个解决方案,但它不起作用。
<a href="facebook-frame.php?all" data-target="#facebook-friends" role="button" class="btn btn-primary" data-toggle="modal">这是我主页上的模式:
<div class="modal fade hide" id="facebook-friends" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Inviter veninder fra Facebook</h3>
</div>
<div class="modal-body text-center">
<p>Loading content...</p>
<p><IMG src="ajax-loader.gif"></p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Luk</button>
</div>
</div>我特别喜欢“加载内容”,因为它看起来非常动态。
有没有办法给facebook-frame.php中的链接/按钮分配一个特殊的命令/类/名称,这样当点击它时,它会暂时显示“正在加载内容”,同时加载请求的页面(在href属性中)?
发布于 2013-03-10 06:26:34
如果我没理解错的话,在facebook-frame.php中,你能像这样捕获所有的<a> (或特定的<a>类)点击事件吗?
$(document).on('click', '#facebook-friends a', function(e) {
e.preventDefault();
// show the "Loading content" message
// load the content and whatever else you need to do
});注意:.on()需要jQuery 1.7+。在此之前,您将使用.live()。
https://stackoverflow.com/questions/15314596
复制相似问题