[英]Wordpress JQuery Conflict (theme and plugin)
A wordpress website I am developing is throwing an error with the QTip tooltip function. 我正在开发的wordpress网站使用QTip工具提示功能引发错误。 The theme I am using is called Eventum and the tooltip is included in the calendar of the Event Espresso Plugin.
我使用的主题称为Eventum,工具提示包含在Event Espresso插件的日历中。 With a default WP theme, the calendar works just fine, but with the Eventum theme it is giving the following error:
使用默认的WP主题,日历可以正常工作,但是使用Eventum主题,则会出现以下错误:
Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value).done is not a function
at QTip.PROTOTYPE._waitForContent (jquery.qtip.js?ver=2.2.0:633)
at QTip.PROTOTYPE._update (jquery.qtip.js?ver=2.2.0:618)
at QTip.PROTOTYPE._updateTitle (jquery.qtip.js?ver=2.2.0:642)
at QTip.PROTOTYPE.render (jquery.qtip.js?ver=2.2.0:187)
at QTip.<anonymous> (jquery.qtip.js?ver=2.2.0:1501)
at d (jquery.js?ver=1.12.4:2)
The theme uses wp_enqueue_script for the JQuery functionality and other than that I can't see why it isn't working. 该主题将wp_enqueue_script用于JQuery功能,除此之外,我看不出为什么它不起作用。 The function which is breaking from the qtip.js file is:
打破qtip.js文件的功能是:
PROTOTYPE._waitForContent = function(element) {
var cache = this.cache;
// Set flag
cache.waiting = TRUE;
// If imagesLoaded is included, ensure images have loaded and return promise
return ( $.fn.imagesLoaded ? element.imagesLoaded() : $.Deferred().resolve([]) )
.done(function() { cache.waiting = FALSE; })
.promise(); };
Any ideas how to fix the error? 任何想法如何解决该错误?
I think in Worpress you can't use $ directly. 我认为在Worpress中您不能直接使用$。 Not sure why they don't add that but try with
jQuery
instead of $
不知道为什么他们不添加,而是尝试使用
jQuery
而不是$
Ok, I think the issue is still with javascript. 好的,我认为问题仍然在于javascript。 See if $.fn.imagesLoaded and $.Deferred are defined in your theme.
查看是否在主题中定义了$ .fn.imagesLoaded和$ .Deferred。 It looks like one or other is not defined and not returning a promise() so undefined.done() throws an error.
看起来一个或另一个未定义且未返回promise(),因此undefined.done()引发错误。 If imagesLoaded() is defined then I don't think it should throw that eror.
如果定义了imagesLoaded(),那么我认为它不会抛出该错误。 Most likely it is not defined so it falls under $.Deferred() function which is also undefined.
很可能没有定义,因此它属于$ .Deferred()函数,该函数也未定义。 You may need to get imagesLoaded function and include that script before.
您可能需要获取imagesLoaded函数并在其中包含该脚本。 Which most likely solve your issue
哪个最有可能解决您的问题
http://imagesloaded.desandro.com/ http://imagesloaded.desandro.com/
https://api.jquery.com/jquery.deferred/ https://api.jquery.com/jquery.deferred/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.