Jump to content

I think i have jquery conflict problem help please


Lisa23

Recommended Posts

Hi i have a site which a use a slideshow which has its own js files to work and a jquery tabs which also has its own js files, but now since i had both those src files into the head of my page only one works, it seems i cant have both src files.

 

I have googled about the jquery conflict function but i just dont think i can get the sintax correct can someone help me out please? thanks in advance

I've separated the files with html coment ofr better visual the files i need are SLIDESHOW files, and TABS file.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>People Smart Learning</title>
<link rel="stylesheet" type="text/css" href="stylesheets/main.css" />
<link rel='stylesheet' id='style-css'  href='slide-show/diapo.css' type='text/css' media='all'>
<link type="text/css" href="js/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
<meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />

<!-- START SLIDESHOW FILES  -->
<script type='text/javascript' src='slide-show/scripts/jquery.min.js'></script>
<!--[if !IE]><!--><script type='text/javascript' src='slide-show/scripts/jquery.mobile-1.0rc2.customized.min.js'></script><!--<![endif]-->
<script type='text/javascript' src='slide-show/scripts/jquery.easing.1.3.js'></script>
<script type='text/javascript' src='slide-show/scripts/jquery.hoverIntent.minified.js'></script>
<script type='text/javascript' src='slide-show/scripts/diapo.js'></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js"></script>
<script>
    $(function(){
        $('.pix_diapo').diapo();
    });
</script>
<!-- END SLIDESHOW FILES FOR  -->


<!-- START CONTACT FORM FILES -->
<script type="text/javascript" src="form/validation/validation.js"></script>
<script type="text/javascript">
        var nameError = '<?php echo $error_messages['fullname']; ?>';
        var emailError = '<?php echo $error_messages['email']; ?>';
        var telephoneError = '<?php echo $error_messages['telephone']; ?>';
        var commentError = '<?php echo $error_messages['comment']; ?>';
    </script>
<!-- START CONTACT FORM FILES -->


<!--START TAB FILES-->
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
<script type="text/javascript">
    $(function(){
        // Tabs
        $('#tabs').tabs();
    });
</script>
<!-- END TABS FILES -->

</head>

Link to comment
Share on other sites

I would strongly encourage you to stick to just one framework. Generally JS frameworks internally contain the same stuff, so you're just doubling the resources needed for no good reason.

 

If you still want to go ahead for whatever reason, then you'll need to use jQuery.noConflict() (or the mootools equivalent) to remove the global $ alias variable, as both frameworks by default use this as a shorthand. You'll then need to invoke jQuery using jQuery, instead of $. For example:

 

$('...');

 

Would become:

 

jQuery('...');

 

However using $ does speed up development a bit and keep your code cleaner, so you could use an 'immediate function' with a local-only $ alias instead:

 

(function($) {
    // Normal $ jQuery calls here
})(jQuery);

 

jQuery also supports this in the .ready() event:

 

jQuery(document).ready(function($) {
    // Normal $ jQuery calls here
});

Link to comment
Share on other sites

Hi thanks for the help, i managed to get to work with the conflict script, but like you said if i could use just one library source would do the job i would the problem is whenever i take one of those js files the function don't work, if you know which or how i can remove and just keep one js file i would appreciate the help, if you cant i still appreciate the help already thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.