Twitter Bootstrap + Mootools +尝试使用弹出窗口时出现 JQuery.NoConflict() 问题
我在 bootstrap-dropdown.js 中使用 JQuery.NoConflict() ,让 mootools 和 Twitter Bootstrap (使用 JQuery 实现其 Javascript 功能)几乎可以“很好地”工作。
好吧,现在我尝试使用 bootstrap-popover.js,但它的工作不如 bootstrap-dropdown.js 顺利。嗯,我想这是一个我不太理解的兼容模式问题。
我有这个 javascript 错误:
<script type="text/javascript">
$(function () {
$('td[rel=popover]')
.popover({
offset: 10,
live: true
})
.click(function(e) {
e.preventDefault()
})
})
</script>
错误是:
Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function
编辑:
我之前已经成功使用过 popover(但不是使用 mootools),并且我尝试重复相同的方式和代码。就在这个有错误的 javascript 代码之前,我链接了这样的文件(已成功加载):
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="../js/html5.js"></script>
<script src="../js/bootstrap-dropdown.js"></script>
<script src="../js/bootstrap-alerts.js"></script>
<script src="../js/bootstrap-twipsy.js"></script>
<script src="../js/bootstrap-popover.js"></script>
<script src="../js/bootstrap-modal.js"></script>
<link rel="stylesheet" type="text/css" href="../css/bootstrap.css" />
我知道 之间应该更好,但它应该在
内也能正常工作,并且它也适用于其他
bootstrap-alerts.js
和 dropdown
。 另外,我在 中以这种方式调用弹出窗口:
<thead>
<tr>
<th>Título</th>
<th>Data</th>
<th>Horário</th>
<th rel="popover" data-original-title="A title" data-content="And here's some amazing content. It's very engaging. right?">Ticket Associado <img src="../img/alert-icon.gif"></th>
<th>Entrar no Chat</th>
</tr>
</thead>
并且在 twitter-Bootstrap/JQuery 之后调用 mootools。
有什么帮助吗?提前非常感谢!
I have mootools and Twitter Bootstrap (which uses JQuery for their Javascript capabilities) working nearly "well" using JQuery.NoConflict() inside the bootstrap-dropdown.js .
Well, now I'm trying to use bootstrap-popover.js and it's not working as smoothly as bootstrap-dropdown.js. Well I guess that it's a compatibility mode issue that I cannot understand pretty well.
I have this javascript with error:
<script type="text/javascript">
$(function () {
$('td[rel=popover]')
.popover({
offset: 10,
live: true
})
.click(function(e) {
e.preventDefault()
})
})
</script>
And the error is:
Uncaught TypeError: Property '
EDIT:
I've successfully used popover before (but not with mootools) and i tried to repeat the same way and codes. Just before this javascript code with error, i'm linking the files like this (which are successfully loading):
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="../js/html5.js"></script>
<script src="../js/bootstrap-dropdown.js"></script>
<script src="../js/bootstrap-alerts.js"></script>
<script src="../js/bootstrap-twipsy.js"></script>
<script src="../js/bootstrap-popover.js"></script>
<script src="../js/bootstrap-modal.js"></script>
<link rel="stylesheet" type="text/css" href="../css/bootstrap.css" />
I know that it should be better between <head></head>
but it should work as well inside <body>
And it is working for other bootstrap-alerts.js
and dropdown
.
Also, I'm calling the popover this way in a <table>
:
<thead>
<tr>
<th>Título</th>
<th>Data</th>
<th>Horário</th>
<th rel="popover" data-original-title="A title" data-content="And here's some amazing content. It's very engaging. right?">Ticket Associado <img src="../img/alert-icon.gif"></th>
<th>Entrar no Chat</th>
</tr>
</thead>
And mootools are being called after twitter-Bootstrap/JQuery.
Any help? Thank you so much in advance!
of object [object DOMWindow] is not a function
EDIT:
I've successfully used popover before (but not with mootools) and i tried to repeat the same way and codes. Just before this javascript code with error, i'm linking the files like this (which are successfully loading):
I know that it should be better between <head></head>
but it should work as well inside <body>
And it is working for other bootstrap-alerts.js
and dropdown
.
Also, I'm calling the popover this way in a <table>
:
And mootools are being called after twitter-Bootstrap/JQuery.
Any help? Thank you so much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
呃。似乎 Twitter 弹出窗口代码存在问题,比任何事情都更有可能。
对象 [object DOMWindow] 的属性“$”不是函数
- 听起来好像 $ 不是您想象的那样。我认为 noConflict 的要点是恢复使用jQuery()
而不是$
- 您发布的代码并不完全是这样做的。相反 - mootools,如果在 jquery 之后加载并且版本为 1.2.3 或更高版本,则不会接管
$
声明并回退到document.id
。什么时候会出现异常、运行时或者与弹出框元素交互时? do
console.log(window.$)
并查看声明它的内容,听起来它是一个原始对象属性而不是函数。你运行任何需要使用 $ 的特定 mootools 东西吗?需要比您提供的更多的数据。
您可能想要查看的一件事是 BootStrap 的 MooTools 端口:http://dev。 clientcide.com/?version=MooTools%20Bootstrap - 仍在进行中,但它具有重要的内容。
erm. seems as if there's an issue with the twitter popover code, more likely than anything.
Property '$' of object [object DOMWindow] is not a function
- sounds as if the $ is not what you think it is. I thought the point of noConflict was to revert to usingjQuery()
and not$
- the code that you post is not exactly doing that.conversely - mootools, if loaded AFTER jquery and if of version 1.2.3 or higher, will NOT take over the
$
declaration and fallback todocument.id
instead.when do you get the exception, runtime or when you interact with a popover element? do
console.log(window.$)
and see what has declared it, it sounds like it's a primitive object property and not a function.do you run any specific mootools stuff that requires use of $? need more data than what you have provided.
one thing you may want to look at is the MooTools port of BootStrap here: http://dev.clientcide.com/?version=MooTools%20Bootstrap - still a work in progress but it has the important stuff.