0

I am using custom scroll and accordion in a page but when I put both plugin's script in the page thn either one of tat is not working. I tried to merge both but still it is not working.

Here is my script for each plugin

For custom scroll

<script type="text/javascript" src="js/jquery.min1.7.2.js"></script>
<script type="text/javascript" src="js/jquery.tinyscrollbar.min.js"></script>
 <script type="text/javascript">
        $(document).ready(function(){
            $('#scrollbar1').tinyscrollbar();   
             $('#maintab').tabs();              
        });
    </script>

For accordion

<script type="text/javascript" src="js/jquery.js"></script> 
<script type="text/javascript" src="js/accordion.js"></script>
<script type="text/javascript">
jQuery().ready(function(){  
    // applying the settings
    jQuery('.theMenu').Accordion({
        active: 'h3.selected',
        header: 'h3.head',
        alwaysOpen: false,
        animated: true,
        showSpeed: 400,
        hideSpeed: 800
    });
}); 
</script>
1
  • Maybe because they are minified and some functions may interfere with each other, having the same name.
    – Angel
    Jul 24, 2012 at 8:58

1 Answer 1

0

You are using 2 Jquery Libraries. Use Only one (the latest one) at the top of all scripts so your code should be like this:

<script type="text/javascript" src="js/jquery.min1.7.2.js"></script>
<script type="text/javascript" src="js/jquery.tinyscrollbar.min.js"></script>
<script type="text/javascript" src="js/accordion.js"></script>

or see this post: Inclusion of more than two jquery libraries

Extracted from above post:

<script src="http://code.jquery.com/jquery-1.7.2.js"></script>
<!-- other scripts that depend on 1.7.2 --->
<script>
    var $.1.7.2 = $.noConflict(true);
</script>

<script src="http://code.jquery.com/jquery-1.2.6.js"></script>
<!-- other scripts that depend on 1.2.6 --->
<script>
    var $.1.2.6 = $.noConflict(true);
</script>

Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using `. If we need to use another JavaScript library alongside jQuery, we can return control of $ back to the other library with a call to $.noConflict():

See Also: jQuery.noConflict

10
  • I tried adding only one library file but still it doesnt work
    – Sowmya
    Jul 24, 2012 at 9:02
  • I used another accordion which is working fine now. but one question, how do we use the same accordion 2 times in single page? If it has id thn i cant, if i change it to class thn both r behaving similarly. Do u have any other plugin which work for multiple accorfion in same page
    – Sowmya
    Jul 24, 2012 at 9:54
  • You can do it by initiating accordion function (having different id's) multiple time like jQuery('#id1').Accordion({}) and jQuery('#id2').Accordion({}) and so on... Jul 24, 2012 at 10:01
  • var nestedAccordion=new TINY.accordion.slider("nestedAccordion"); nestedAccordion.init("nested","h3",1,-1,"acc-selected"); this is the code am using for accordion. How can I make multiple accordion with this code
    – Sowmya
    Jul 24, 2012 at 10:08
  • one last question :) above sample is nice but how to close all the tabs by default? not the frst tab is opened by default in that code
    – Sowmya
    Jul 24, 2012 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.