Bootstrap 2.3.1 - 带遥控器的 Modal 不会第一次加载,但会在第一次之后加载 [英] Bootstrap 2.3.1 - Modal with remote doesn't load first time, but does after the first time

查看:37
本文介绍了Bootstrap 2.3.1 - 带遥控器的 Modal 不会第一次加载,但会在第一次之后加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个加载远程内容的引导模式.这在第一次点击链接时不起作用.模式出现,但未加载远程内容.我查看了日志,远程调用也没有进行.

I have a bootstrap modal that loads remote content. This does not work the first time the link is click. The modal comes up, but remote content is not loaded. I checked the logs, and the remote call is not even made.

如果我单击该链接第二次或更多次,它就可以正常工作.我最初使用标准的 bootsrap 链接方法,但后来改为纯 javascript,希望获得更多控制.链接点击功能现在是:

If I click the link a second or more times, it works perfectly. I originally was using the standard bootsrap link method, but have since changed to pure javascript hoping to get more control. The link click function is now:

$(function() {
                 $(".modal-link").click(function(event) {
                     $('.modal-body').text('Loading content...');
                     var modal = new $.fn.modal.Constructor();
                     $('#myModal').modal({keyboard: true})
                                  .remote($(this).attr("href"))
                                  .show();

                 })
             })

它每次都会被调用,模型每次都会出现,但它只在第一次之后进行远程调用.远程调用是对同一个域/机器的.(所有这些都在一个 grails 应用程序中.)

It gets called every time, and the model comes up every time, but it only makes the remote call after the first time. The remote call is to the same domain/machine. (All of this is inside a grails app.)

有什么想法吗?我不知道还有什么可以尝试的.

Any ideas? I'm not sure what else to try.

推荐答案

我从来没有弄清楚为什么 Bootstrap 没有正确加载它,但确实使用了以下解决方法:

I never did figure out why Bootstrap wasn't loading it properly, but did use the following work around:

$('.modal-body').text('Loading content...');
if (firstLoad) {
      $('#myModal .modal-body').load($(this).attr("href"))
      firstLoad = false;
 }

布尔值 firstLoad 回退到 jquery 以仅在第一次加载时加载 div 内容.

The boolean firstLoad falls back to jquery to load the div content on the first load only.

这篇关于Bootstrap 2.3.1 - 带遥控器的 Modal 不会第一次加载,但会在第一次之后加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆