jQuery noConflict() | Lessoncup Programming Blog

Saturday, 9 November 2013

jQuery noConflict()

HI, today i am going to tell you about avoiding problems form jQuery and other libraries, as we working on sometimes we use other frameworks like mootools.js, backbone.js and other along with jQuery, at this case some of the script will not work that could be jQuery or other related frameworks. basically the jquery frameworks start with jquery namespace and all global methods and objects are stored inside the jQurey namespace.


so there is no chance to conflict the script, but there is one problem comes with $ sign character, it is  a shortcut, because in jquery we use to call every thing using $ sign character and other frameworks also, in that case the scripts stop working. To avoid this problem jQuery providing noConflict() method to resolve this issue.
<script src="mootools.js"></script>

<script src="jquery.js"></script>

<script>

$.noConflict();
jQuery( document ).ready(function( $ ) {

  // your jQuery code

});

</script>


No comments :

Post a Comment

Mohammad Khasim
Blogger | Web Developer
Hyderabad - INDIA
lessoncup@gmail.com

PHP | My SQL | JQUERY
Web Development Tools | CMS | Frameworks | SEO

Get my Latest Lessons