首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重新加载modal单击时modal中的内容

重新加载modal单击时modal中的内容
EN

Stack Overflow用户
提问于 2013-03-10 02:55:55
回答 1查看 1.6K关注 0票数 0

我有一个非常简单的jQuery-script,用于根据链接更改模式内容。代码:

代码语言:javascript
复制
$('#facebook-friends').on('hidden', function () {
  $(this).removeData('modal');
});

然后,我可以根据按钮控制要使用的内容:

代码语言:javascript
复制
<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中尝试过这个解决方案,但它不起作用。

代码语言:javascript
复制
<a href="facebook-frame.php?all" data-target="#facebook-friends" role="button" class="btn btn-primary" data-toggle="modal">

这是我主页上的模式:

代码语言:javascript
复制
    <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属性中)?

EN

回答 1

Stack Overflow用户

发布于 2013-03-10 06:26:34

如果我没理解错的话,在facebook-frame.php中,你能像这样捕获所有的<a> (或特定的<a>类)点击事件吗?

代码语言:javascript
复制
$(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()

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15314596

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档