3

Installed a search extension and now the shopping cart is broken. Am getting a javascript error.

When the extension is disabled everything works fine. The Extension support told me to empty their .js file. But that does not fix the issue.

I don't understand where the $.noConflict(); should go.

6
  • This should help: learn.jquery.com/using-jquery-core/…
    – Shaz
    Commented Aug 27, 2013 at 20:06
  • 1
    This question appears to be off-topic because it is about jQuery.noConflict()
    – philwinkle
    Commented Aug 27, 2013 at 20:34
  • 1
    No it is not, the question is: Where should I put the jQuery.noConflict(); Commented Aug 27, 2013 at 20:54
  • Good question. I didn't even know of noConflict. I rewrote some jQuery code to use jQuery instead of $ to get around the problem. Commented Aug 27, 2013 at 23:10
  • I don't think it's off topic, but it's a duplicate of a common question
    – Roscius
    Commented Aug 28, 2013 at 3:03

2 Answers 2

3

open up your included jQuery file and add to the last line. You can see from view-source from where it is included:

jQuery = jQuery.noConflict(); 

or just

jQuery.noConflict();
1
  • OK - so I added jQuery.noConflict(); to the last line of the jquery.min.js file included in the extension and it did nothing to help. Other ideas? The extension is Sphinx Search @anton
    – Wesley
    Commented Aug 29, 2013 at 20:03
3

jQuery is conflicting with Magento's out of the box javascript library, Prototype.

See question: Toggle menu/accordion menu doesn't work?

You can wrap the javascript code from the extension in an anonymous no-conflict wrapper eg:

(function ($) {

....
(extension code here)
....

})(jQuery.noConflict()); 

The main issue that arises between jQuery and Prototype is contention for the $ operator, which jQuery uses as a short form for the jQuery function. You should be able to get an idea of the code that is conflicting from the javascript error message.

6
  • An answer which is a link to another answer which is basically two links. Care to elaborate? Include some content please.
    – philwinkle
    Commented Aug 28, 2013 at 3:31
  • 1
    @philwinkle The links in the other answer (which is to a question which is a duplicate of this one) are to canonical jQuery resources and answer the question. No point in cut and pasting content from either in to this answer. Feel free to a) Edit my answer, b) add an answer of your own, or c) down vote the answer if it's that bad.
    – Roscius
    Commented Aug 28, 2013 at 5:44
  • just pitching in to help keep the community clean. Nothing personal mate. meta.stackexchange.com/questions/72000/…
    – philwinkle
    Commented Aug 28, 2013 at 12:53
  • @roscius I had already seen that post and the links - but that still did not answer my question.
    – Wesley
    Commented Sep 3, 2013 at 22:04
  • @Wesley I've added some more info, if you're still having the problem, it would be helpful for you to post the error message you are receiving in to your question.
    – Roscius
    Commented Sep 4, 2013 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.