简体   繁体   中英

Wordpress JQuery Conflict (theme and plugin)

A wordpress website I am developing is throwing an error with the QTip tooltip function. The theme I am using is called Eventum and the tooltip is included in the calendar of the Event Espresso Plugin. With a default WP theme, the calendar works just fine, but with the Eventum theme it is giving the following error:

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. The function which is breaking from the qtip.js file is:

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. Not sure why they don't add that but try with jQuery instead of $

UPDATE

Ok, I think the issue is still with javascript. See if $.fn.imagesLoaded and $.Deferred are defined in your theme. It looks like one or other is not defined and not returning a promise() so undefined.done() throws an error. If imagesLoaded() is defined then I don't think it should throw that eror. Most likely it is not defined so it falls under $.Deferred() function which is also undefined. You may need to get imagesLoaded function and include that script before. Which most likely solve your issue

http://imagesloaded.desandro.com/

https://api.jquery.com/jquery.deferred/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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