Dr.CustUmz
03-04-2015, 06:21 PM
this time I have a tip, i have been creating alot of mods recently with alot of jquery and keeping mods enabled and testing others sometimes resulted in a clash, also known as a jQuery conflict.
the easiest method for resolving these issues (that i use atleast) is to wrap my whole <script>
here's an example, i have this script on my page:
<script type="text/javascript">
$(document).ready(function() {
$('#someID').someThing();
});
</script>
I install a mod that uses jQuery and all of a sudden my script no longer works and i have errors in my console. what do i do!?
well it's simple wrap it up like so:
<script type="text/javascript">
jQuery.noConflict();
(function( $ ){
$(document).ready(function() {
$('#someID').someThing();
});
})( jQuery );
</script>
you can use this method in .js files too and it almost always will fix any issues, assuming your script worked in the first place.
so prevent it from clashing from the start and wrap your code whenever you start
<script type="text/javascript">
jQuery.noConflict();
(function( $ ){
YOUR SCRIPT HERE HERE
})( jQuery );
</script>
the easiest method for resolving these issues (that i use atleast) is to wrap my whole <script>
here's an example, i have this script on my page:
<script type="text/javascript">
$(document).ready(function() {
$('#someID').someThing();
});
</script>
I install a mod that uses jQuery and all of a sudden my script no longer works and i have errors in my console. what do i do!?
well it's simple wrap it up like so:
<script type="text/javascript">
jQuery.noConflict();
(function( $ ){
$(document).ready(function() {
$('#someID').someThing();
});
})( jQuery );
</script>
you can use this method in .js files too and it almost always will fix any issues, assuming your script worked in the first place.
so prevent it from clashing from the start and wrap your code whenever you start
<script type="text/javascript">
jQuery.noConflict();
(function( $ ){
YOUR SCRIPT HERE HERE
})( jQuery );
</script>