mootools formcheck插件和jquery冲突
我页面上都有mootools和jquery。但是当页面上调用jquery时,mootools插件(formcheck)不起作用。 firebug 在控制台中给出此错误:
this.form.getProperty is not a function at line 314 of formcheck.js
这是该行的代码:
this.form.setProperty('action',
this.options.submitAction || this.form.getProperty('action') || 'post');
我不明白问题是什么。 你愿意帮助我吗?
I have mootools and jquery both on the page.But the mootools plugin (formcheck) doesn't work when the jquery is called on the page.
firebug gives this error in console:
this.form.getProperty is not a function at line 314 of formcheck.js
Here's the code of that line:
this.form.setProperty('action',
this.options.submitAction || this.form.getProperty('action') || 'post');
I don't understand what the problem is.
Would you help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我之前遇到过类似的问题,我通过将 jQuery 代码中的 $ 替换为 jQuery 一词来修复它,
例如:
将是:
I faced a similar problem before and I fixed it by replacing the $ in the jQuery code to the word jQuery
For example:
will be:
如果 jQuery 是问题所在,请尝试使用名为 noConflict() 的内置功能。
你可以这样调用它:
然后你可以像这样包装你原来的 $(...) 代码:
If jQuery is the problem, try using the built-in feature named noConflict().
You can call it like this:
Then you can wrap your original $(...) code like this:
这也是从 mootools 角度来看的答案。
可能更进一步,就像在初始化方法中一样,您有类似的内容:
由于 jquery 不返回实际元素,而是返回其本身的包装元素,因此它将失败,因为 jquery 没有
setProperty
方法。用 document.id 替换 mootools 类中所有提及 $() 的内容,或者将其放入隐式设置它的闭包中。mootools 自版本 1.2.2 或 1.2.3 以来就有了 document.id 后备,不记得了。事实上,从该版本开始,如果已经设置了 $ ,它就不会重新定义它,并且只会依赖 document.id 来工作。
因为你在类中使用了 setProperty,所以我认为你可能使用的是 mootools 1.1x - 在这种情况下,没有可用的后备,并且你在 jquery 方面陷入了
noConflict
。here's an answer from the mootools perspective as well.
probably further up, like inside your initialize method, you have something like:
due to jquery not returning the actual element but a wrapped element in itself, it will fail as jquery does not have a
setProperty
method. replace all mentions of $() in the mootools class with document.id or put it inside a closure that implicitly sets it.mootools has had a document.id fallback since version 1.2.2 or 1.2.3, can't remember. in fact, since that version, it won't redefine $ if already set and will only rely on document.id to work.
since you use setProperty in the class, it leads me to think you may be using mootools 1.1x - in which case, no fallback will be available and you're stuck with
noConflict
on the jquery side.