Accordion Events Don't Shoot

I have warnings that should trigger "activate" and "beforeActivate" events. Neither one nor the other happens.

Javascript

$(function () { $(".accordion").accordion({ collapsible: false, active: true, activate: function (event, ui) { alert("activate"); }, beforeActivate: function (event, ui) { alert("before activate"); } }); }); 

HTML

 <div> <ul> <li>0</li> <div class="accordion"> <li> <h3><a href="#">First</a></h3> <div> <ul> <li>1</li> <li>2</li> </ul> </div> </li> <li> <h3><a href="#">Second</a></h3> <div> <ul> <li>3</li> <li>4</li> </ul> </div> </li> </div> </ul> </div> 

I know about incorrect html in the div nest away from ul.

+4
source share
3 answers

Have you verified and included the correct link in the jQueryUI library?

Cdn

 <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.js'></script> 

Normal file link

 <script type='text/javascript' src='.../yourDirectory/jquery-ui.js'></script> 

The following is a working example that works correctly after turning on the jQuery UI link.

Example

+3
source

If you are using 1.8, then you want to use change and changestart as events:

 $( ".selector" ).accordion({ change: function( event, ui ) {} }); 

http://api.jqueryui.com/1.8/accordion

+12
source
In jQuery UI 1.8 events

activate and beforeActivate do not exist, which explains why warnings do not fire.

As mentioned by Schaz, in jQuery UI 1.8 these events are called change and changestart .

https://api.jqueryui.com/1.8/accordion/

Starting with jQuery UI 1.9, the event name has changed to activate and beforeActivate .

https://api.jqueryui.com/1.9/accordion/

Additional Information:

http://jqueryui.com/changelog/1.9.0/#accordion
Deprecated: changestart event; renamed to beforeActivate. (#6840, 088ef05, e0fe788) Deprecated: changestart event; renamed to beforeActivate. (#6840, 088ef05, e0fe788) Deprecated: change event; renamed to activate. (#6842, 088ef05, e0fe788) Deprecated: change event; renamed to activate. (#6842, 088ef05, e0fe788)

0
source

All Articles