jackmoore / colorbox

A light-weight, customizable lightbox plugin for jQuery
http://www.jacklmoore.com/colorbox/
MIT License
4.75k stars 1.14k forks source link

Can't figure out how to get this to work in noconflict() mode #830

Closed ygagnon closed 7 years ago

ygagnon commented 7 years ago

I can't seem to figure out how to get this one line of code to work in JQuery's noconflict() mode.

$.colorbox({html: ... });

(Can't seem to get this code to render correctly in here .. so I've intentionally shortened it)

Please advise on how I would accomplish this.

Thanks,

jackmoore commented 7 years ago

This isn't enough information to address your question with any confidence. It may be as easy as replacing $.colorbox with jQuery.colorbox, but it depends on what you have going on.

ygagnon commented 7 years ago

I'm trying to get this working on a Wordpress site .. in my functions.php file. I already have the jquery and colorbox libraries loaded in my theme.

jackmoore commented 7 years ago

Just to make sure, you know that jQuery.noConflict() does, right? It assigns the $ alias to whatever it was prior to referencing jQuery. Unless you've created a local variable for $ to reference jQuery, you have to fall back to using jQuery in your code.

jackmoore commented 7 years ago

All of this is unrelated to Colorbox by the way, you could replace Colorbox with any other code using jQuery.

ygagnon commented 7 years ago

Yes, I understand what noConflict() does, and I know how to use it (I've been using it extensively on the site that I'm developing and trying to get this working with. I just can't seem to get it to work with colorbox for some reason (I've already tried "jQuery.colorbox" to no avail).

The colorbox library is part of the Wordpress theme that I'm using (BuddyBoss), and I'm just trying to leverage it to replace the ugly javascript alert() prompts that I've been using temporarily. I just keep getting these perpetual "ReferenceError: jQuery is not defined" errors when I try to implement it within my child theme's functions.php file .. even though the JQuery library is definitely loaded, and I'm referencing it extensively in that same functions.php file. I'm stumped, frankly, .. which is why I thought it might be worthwhile for me to go right to the source.