html - how to solved two jquery confliction specially autocomplete and fullcalendar js -
i want include 2 jquery files (one auto complete ajax , other full calendar) on same page/ header page conflict each other. how can solved issue, tried solution of noconflict no use, please me.
following code include js file:
<script src="js/jquery-1.2.1.min.js" type="text/javascript"></script> <script src="js/fullcalendar/jquery.min.js" type="text/javascript"></script>
where first file used auto complete dropdown , other 1 full calendar event.
thanks in advance.
edit: sorry, saw tried noconflict after posting this. reason think not work if not wanting update $/jquery names in 1 of files. find , replace pretty easily.
i recommend using jquery.noconflict(true) remove jquery object global scope , assign object name of choosing, provided don't need use precise object name: jquery/$ access jquery object both versions. can 1 of versions after inclusion.
for example: jq121 = jquery.noconflict( true ); let access version 1.2.1 jq121 in global scope. if called after inclusion of 1.2.1, free $ , jquery reference other version.
they have examples here:
https://api.jquery.com/jquery.noconflict/
edit: put quick example. below code can access newer version jq214 , older version default $ alias.
<html> <head> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script> </head> <body> <script> $(document).ready(function(){ jq214 = jquery.noconflict( true ); jq214(document.body).append("jq214 object name version " + jq214.fn.jquery); $(document.body).append("<br/>default $ alias version " + $.fn.jquery); }); </script> </body> </html>
i should mention though jquery team mentions (as others here do) including 2 versions should avoided if possible.
Comments
Post a Comment