简体   繁体   English

Twitter Bootstrap:使用远程选项渲染模式时控制台js错误

[英]Twitter Bootstrap: console js error while rendering Modals with remote options

I have a problem with Modals and remote option: if i provide a remote href for loading the content of modal popup from that url, when modal window appear I get this error in console: 我有一个问题, 情态动词和远程选项:如果我从该网址加载模式弹出的内容提供远程的href,当模式窗口出现在我的控制台得到这个错误:

"Error: Syntax error, unrecognized expression: /my/url" (jquery.min.js row2)

anybody with the same problem and/or solution? 任何有相同问题和/或解决方案的人?

I have the same problem with bootstrap 3. It works nice with an inline load ( href="#id" ) but same error when trying to load remote content, either via href="remote/url" or data-target="remote/url" 我在引导程序3中也遇到了同样的问题。它在内联加载( href="#id" )时效果很好,但是在尝试通过href="remote/url"data-target="remote/url"加载远程内容时出现相同的错误data-target="remote/url"

Edit: 编辑:

I've found the correct way to do it. 我找到了正确的方法。

Bootsrap allways need a modal container, to inject the ajax loaded content in it. Bootsrap始终需要一个模式容器,以将ajax加载的内容注入其中。 Thus, you need to give to your link both attribute: the remote target and the div to show. 因此,您需要为链接提供两个属性:远程目标和要显示的div。

Here is the simplest way: 这是最简单的方法:

<!-- The modal trigger link -->
<a data-toggle="modal" href="http://your/link" data-target="#my-modal" >modal link</a>

<!-- Invisible modal to render content -->
<div class="modal fade popin" id="my-modal" tabindex="-1" role="dialog" aria-hidden="true"></div>

I had the same problem. 我有同样的问题。 The solution is to use data-href attribute instead of href : 解决方案是使用data-href属性而不是href

<a data-toggle="modal" data-href="http://your/link" data-target="#my-modal" >modal link</a>

As href value, Bootstrap modal expects valid selector. 作为href值,Bootstrap模态期望有效的选择器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM