The public methods below allow you to manipulate the accordion using external controls. There are two ways of calling a public method.
The first way is by calling the
accordionSlider plugin and passing the name of the method and additional arguments:
The first argument represents the name of the method and the second argument represents the value which will be applied. Please note that some methods don't have a second argument. For example:
The second way is by getting a reference to the AccordionSlider instance and calling the method on the instance:
// get a reference to the AccordionSlider instance var accordion = $('#my-accordion').data('accordionSlider'); console.log(accordion.getTotalPanels()); accordion.gotoPage(2);
This way of calling a public method is mandatory when you use public methods that return data:
getCurrentPage , but it can be used with all the other public methods as well.
Here is the list of available public methods:
Gets all the data of the panel at the specified index. Returns an object that contains all the data specified for that panel.
Gets the index of the current panel.
Gets the total number of panels.
Opens the next panel.
Opens the previous panel.
Opens the panel at the specified index.
Closes all the panels.
Gets the number of visible panels.
Gets the number of pages.
Gets the index of the page currently displayed.
Scrolls to the specified page.
Goes to the next page.
Goes to the previous page.
Adds an event listener to the accordion. More details about the use of this method will be presented in the 'Callbacks' chapter.
Removes an event listener from the accordion.
Destroys an accordion by removing all the visual elements and functionality added by the plugin. Basically, it leaves the accordion in the state it was before the plugin was instantiated.
This is called by the plugin automatically when a property is changed. You can call this manually in order to refresh the accordion after changing its HTML, like removing or adding panels.
Removes all the panels.
This is called by the plugin automatically, when the browser window is resized. You can also call it manually if you find it necessary to have the accordion resize itself.