lbh2011 Posted January 27, 2012 Share Posted January 27, 2012 Hi, Please could someone help me out - I'm sure the answer is very simple, but basically I have two scripts which I need to combine so that they work in parallel. Unfortunately I can't provide the rest of the code just yet, but each works on its own but not both together (when placed side by side in the head of the document). The first: <script type="text/javascript" src="js/jquery-1.7.1.min.js" ></script> <script type="text/javascript"> /* <![CDATA[ */ $(document).ready(function(){ $("#Subject").change(function(){ if ($(this).val() == "form1" ) { $("#div1").slideDown("fast"); //Slide Down Effect } else { $("#div1").slideUp("fast"); //Slide Up Effect } }); $("#Subject").change(function(){ if ($(this).val() == "form2" ) { $("#div2").slideDown("fast"); //Slide Down Effect } else { $("#div2").slideUp("fast"); //Slide Up Effect } }); }); /* ]]> */ </script> The second: <script type="text/javascript" src="js/mootools.js"></script> <script type="text/javascript"> /* <![CDATA[ */ window.addEvent('domready', function(){ $('contact').addEvent('submit', function(e) { new Event(e).stop(); var log = $('log_res').empty().addClass('ajax-loading'); this.send({ update: log, onComplete: function() { log.removeClass('ajax-loading'); } }); }); }); /* ]]> */ </script> Quote Link to comment Share on other sites More sharing options...
.josh Posted January 28, 2012 Share Posted January 28, 2012 jQuery and mootools do not natively get along with each other because by default they use the same $ namespace. I don't have much experience with mootools but I know jQuery provides an easy solution for working with other libraries (and I suspect mootools probably has an equivalent). http://docs.jquery.com/Using_jQuery_with_Other_Libraries However, the *real* answer here is really that you should pick one library or the other instead of using both. Which one is better depends on what you are ultimately trying to do, but based on the code you provided, both of them should be able to do those jobs. The benefits of using a single library are obvious: - less bandwidth consumed - faster load times, since you won't be loading 2 libraries - not having to maintain multiple frameworks - don't have to learn multiple frameworks - don't have to deal with issues like this Quote Link to comment Share on other sites More sharing options...
lbh2011 Posted January 28, 2012 Author Share Posted January 28, 2012 I found the solution to my issue here: http://www.phpbb.com/community/viewtopic.php?f=46&t=2125887 Thanks for the suggestions Josh Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.