473,503 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Known jQuery/Prototype conflict - problems solving it, though

97 New Member
I am using prototype and jquery, and as noted on many sites, there is some potential for conflicts. Now, I saw as well again and again this solution:
Expand|Select|Wrap|Line Numbers
  1.  <html>
  2.  <head>
  3.    <script src="prototype.js"></script>
  4.    <script src="jquery.js"></script>
  5.    <script>
  6.      var $j = jQuery.noConflict();
  7.  
  8.      // Use jQuery via $j(...)
  9.      $j(document).ready(function(){
  10.        $j("div").hide();
  11.      });
  12.  
  13.      // Use Prototype with $(...), etc.
  14.      $('someid').hide();
  15.    </script>
  16.  </head>
  17.  <body></body>
  18.  </html>
Now, I have another, quite long javascript file which is being included and references jquery. There are lots of "$" refrences, such as "function($)", "$this.css", "$(_tagMain).data"...

Do I need to replace then all of the "$" with "$j"? Or could it be that I will then badly reference some of these calls/methods?
May 25 '10 #1
5 2608
Dormilich
8,658 Recognized Expert Moderator Expert
If I see it right, Prototype uses $, thus (and because jQuery is set to $j) anything you call using $ will try to execute the Prototype Framework.

if you want to use jQuery, you have to use $j.
May 25 '10 #2
luftikus143
97 New Member
if you want to use jQuery, you have to use $j.
Yes, that's something I understood. The question is more, if I need to replace each and every occurrence of "$" with "$j" in the JS file which uses jQuery?
May 25 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
The question is more, if I need to replace each and every occurrence of "$" with "$j" in the JS file which uses jQuery?
that’s what the sentence implies. $ → Prototype, $j → jQuery. thus if you want to use jQuery (be it existing code or not) you have to use, resp. rewrite it to $j.
May 25 '10 #4
acoder
16,027 Recognized Expert Moderator MVP
I know this doesn't directly answer the question, but it's an important point nonetheless. Is there any reason why you need to use both prototype and jQuery? You should never really need to use more than one library/framework.
May 25 '10 #5
luftikus143
97 New Member
@acoder
Yes, I thought about that question too. But unfortunately, it seems that yes, as I have on lib using scriptaculous, and another one using jQuery.
May 25 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

28
2600
by: Diodeus | last post by:
I would like to set up an event observer outside of an object, so I can't use this.bindAsEventListener. How can I pass the correct object reference? I tried something like this, and various...
5
1751
by: outofmymind | last post by:
Hi every1, im trying to solve this question, i did some of it but i dont think that its correct or complete: this is the question: Write the definition of a class called Product. A Product...
1
2091
by: hedgehog | last post by:
I've always been a do-it-yourselfer when it comes to referencing DOM, doing lil animations and Ajax queries, etc, but I thought I'd give someone else's toolkit a spin. Aside from sorting out...
5
3555
by: ziobudda | last post by:
Hi, I want ask you if, for a web portal/application, is better prototype or Jquery? I don't want to innesc some type of flame, but after the announce that drupal use JQuery and that the new...
5
1495
by: Jens Kleine | last post by:
Hi, I've been having some problems with system calls. When I create a simple file like this int main(int argc, char *argv) { int x; printf("Checking if processor is available...");...
37
1796
by: nolo contendere | last post by:
I've recently begun playing with prototype.js as well as scriptaculous, and found both very helpful in developing web pages with lots of pop. Modal boxes, SlideUp/Down, calendars, etc. I've also...
3
1867
by: kj | last post by:
OK, here's another construct I've run into in the jQuery source that I can't figure out. It looks like this: return new jQuery.prototype.init( selector, context ); So basically, as far as I...
56
2919
by: ashore | last post by:
Guys, I see a fair bit of negativity around re subject package. Can someone share your views, either way? Thanks, AS
83
4109
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
53
8315
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.