MyBB Community Forums

Full Version: Adding external script without conflicting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I need to add this on the header, after the other scripts.

<link rel="stylesheet" type="text/css" href="//de11r67whwhol.cloudfront.net/assets/popup/style.css" /><script type="text/javascript" src="//de11r67whwhol.cloudfront.net/assets/popup/script.js"></script>
Which pretty much adds a jQuery popup and an iframe on that popup.

However, when doing so, a few things break:
  • SCEditor fails to load
  • Shout Box fails to load
  • Prototype errors in console

How can I add this script without breaking everything?
(2013-12-20, 04:56 AM)exotros Wrote: [ -> ]jQuery popup

You need to make sure that you're loading jQuery and calling jQuery.noconflict(), otherwise jQuery and Prototype conflict with use of the $ variable.

See here: http://community.mybb.com/thread-135747.html
(2013-12-20, 05:51 AM)Cameron:D Wrote: [ -> ]
(2013-12-20, 04:56 AM)exotros Wrote: [ -> ]jQuery popup

You need to make sure that you're loading jQuery and calling jQuery.noconflict(), otherwise jQuery and Prototype conflict with use of the $ variable.

See here: http://community.mybb.com/thread-135747.html

I know this, how about for external scripts though? did
<script src="http://......com"></script>
<script>jquery.noConflict();</script>
On the footer

Didn't work though.
Hrmm, I looked through the script you're loading and it seems to have jQuery in it (Rather than loading it separately).

If you're able to edit the script you'd need to call the noConflict() inside the script, just before the last block, then edit the $(document) and $(".buycraft-popup") to read jQuery(...) instead.

The reason its failing now is because by the time it gets to executing the code inside the document ready block $(".buycraft-popup").fancybox no longer exists because it was moved to jQuery.fancybox.

You also need to make sure that you're loading jQuery and calling noConflict before you load Prototype.