Mech0z
Mech0z

Reputation: 3647

Cancel Jquery Accordion close if condition is not met

I have an accordion that on load gets data using ajax to fill it starts getting autoupdates. Then on close I unload the data and removes it from autoupdate list.

But the user can open an Edit page in the accordion, and if this page is open the user should get a warning if he tries to close the accordion e.g. (Closing this will cause you to loose all none saved data) or similar.

So I want to "intercept" the accordion toggle close event and if certain data (The edit page) is loaded inside the accordion a "are you sure" warning should popup.

Upvotes: 0

Views: 344

Answers (1)

Doug English
Doug English

Reputation: 286

$( ".selector" ).accordion({
   changestart: function(event, ui) { 
     ...
     if (dataInvalid) {
       return false;
     }
   }
});

Upvotes: 1

Related Questions