Added/updated in: All versionsVersion 1.2.6Version 1.2
API lets user control, modify and add behaviour and features of the plugin after its initialization, which can be used to create timer, special control buttons and many more useful things. Below you can find a summary of all available methods and public variables with possibility to display detailed explanation and demo(s).
There are 3 methods how to call API methods.
1) API calls can be done inside every callback. In the callback, this always means instance of the accordion.
<script type="text/javascript"> // Avoid conflict with other libraries jQuery(document).ready(function( $ ) { $('.accordion').jAccordion({ // Callback attached to event onReady onReady : function() { this.method(); //Call any API method this.variable; //Access any public variable } }); }); </script>
2) API calls can be done outside callback too. In case there is only one HTML element matching the selector, API calls can be done this way:
<script type="text/javascript"> // Avoid conflict with other libraries jQuery(document).ready(function( $ ) { $('.accordion').jAccordion(); }); $('button').bind('click', function() { $('.accordion').data('jAccordion').method(); // Call any API method $('.accordion').data('jAccordion').variable; // Access any public variable }); </script> <!-- HTML code of accordion --> <div class="accordion"> <!-- Content of accordion --> </div> <button>Do API call</button>
3) In case there are more elements matching the selector, API calls can be done this way (eq(index) specifies index of element):
<script type="text/javascript"> // Avoid conflict with other libraries jQuery(document).ready(function( $ ) { $('.accordion').jAccordion(); }); $('button.first').bind('click', function() { $('.accordion').eq(0).data('jAccordion').method(); // Call any API method of first accordion $('.accordion').eq(0).data('jAccordion').variable; // Access any public variable of first accordion }); $('button.second').bind('click', function() { $('.accordion').eq(1).data('jAccordion').method(); // Call any API method of second accordion $('.accordion').eq(1).data('jAccordion').variable; // Access any public variable of second accordion }); </script> <!-- HTML code of first accordion --> <div class="accordion"> <!-- Content of first accordion --> </div> <button class="first">Do API call</button> <!-- HTML code of second accordion --> <div class="accordion"> <!-- Content of second accordion --> </div> <button class="second">Do API call</button>
Public variable which stores jQuery object of the accordion.
Method attaches callbacks to events. This method is available in jQuery since v1.4.3. Info about combinations of input parameters can be found in jQuery documentation.
Method removes previously attached callbacks. This method is available in jQuery since v1.4.3. Info about combinations of input parameters can be found in jQuery documentation.
Method attaches callbacks to events. This method is available in jQuery since v1.7 and preferred to bind(). Info about combinations of input parameters can be found in jQuery documentation.
Method removes previously attached callbacks. This method is available in jQuery since v1.7 and preferred to unbind(). Info about combinations of input parameters can be found in jQuery documentation.
Method forces resize of accordion. It's useful to call it after accordion's parent was resized via javascript.
Method activates a slide with specified index - slideIndex (if not out of bounds). Slides are numbered from 0, which means that 1st slide equals 0, 2nd slide equals 1 etc. This method internally uses jQuery method eq, which means that you can use all of the advantages of this method such as goToSlide(-1) to activate the last slide.
Method activates the first slide. This method has the same effect as goToSlide(0).
Method activates the last slide. This method has the same effect as goToSlide(-1).
Method activates the next slide or the first slide if none or the last one is active.
Method activates the previous slide or the last slide if none or the first one is active.
Method deactivates all slides. Method takes effect only if a slide is active and autoplay is disabled.
Method returns boolean value which determines whether a slide is opening or closing.
Method returns active slide (if there is one) as jQuery object or null.
Method returns index of active slide or -1 if none is active. Slides are numbered from 0, which means that 1st slide equals 0, 2nd slide equals 1 etc.
Method returns boolean value which specifies whether autoplay is paused.
jAccordion by maniacpc, exclusively for CodeCanyon