JQuery & Prototype Conflict in Mybb
#1
Hello,

In Mybb when you use Jquery, conflict issue arises e.g: Rich textbox, collapse and expand options in different listing pages stops working.

After facing a problem and finding a solution of jQuery and prototype conflict I am sharing the solution with you all.

By default, jQuery uses "$" as a shortcut for "jQuery". However, you can override that default by calling jQuery.noConflict() at any point after jQuery and the other library have both loaded. For example:

 <html>
 <head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     jQuery.noConflict();
     
     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("div").hide();
     });
     
     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>
 </head>
 <body></body>
 </html>

This will revert $ back to its original library. You'll still be able to use "jQuery" in the rest of your application.

If you are using any jQuery library that uses "$" as a shortcut for "jQuery" then you need to replace all "$" with "jQuery". This will solve your problem.

I hope this thread will be helpful for you Smile.

Thanks




Reply
#2
Another "tutorial" on this matter? Really?

Anyway, I'd advise anybody following this guide that they should pass $ as a parameter to the function as there are a few cases where using jQuery just doesn't work - using AJAX being an example I've found in the past.

I suggest using the following instead:

jQuery.noConflict();

jQuery(document).ready(function($)
{
    $('.someClass').hide(); // or whatever you want to do.
});
Reply
#3
(2012-03-16, 11:43 AM)euantor Wrote: Another "tutorial" on this matter? Really?

I agree. This has been known/posted in the community a billion times.
PGP Key (Fingerprint: 23B6 F4C0 FE2D 45AA 61A0 1E86 DB87 09DC DD87 6E40)
Reply
#4
It popped up on Google before the others so I'm thankful.
Reply
#5
Finally. A solution to this madness. Toungue
(Sorry for Necroposting. Just realized how old this was.)
[Image: huesdv.jpg]
Reply
#6
(2012-03-16, 11:43 AM)Euan T Wrote: Another "tutorial" on this matter? Really?

Anyway, I'd advise anybody following this guide that they should pass $ as a parameter to the function as there are a few cases where using jQuery just doesn't work - using AJAX being an example I've found in the past.

I suggest using the following instead:

jQuery.noConflict();

jQuery(document).ready(function($)
{
    $('.someClass').hide(); // or whatever you want to do.
});

Guess it does get annoying to a lot of people, Carn't wait till the new release of mybb it will be using jquery.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)