Use the empty event when creating the accordion, which allows you to control the click event of the accordion using the jQuery.click function. Then you can process the confirmation window and enable the execution of the accordion event only if it is confirmed.
$(document).ready(function()
{
var edited = false,
accordion_me = $('.accordion-me');
accordion_me.accordion({
autoHeight: false,
navigation: true,
event: ''
});
$('.accordion-me h3').click(function()
{
var i = $('.accordion-me h3').index(this);
if (edited && !confirm('You have unsaved changes. Do you want to navigate away?'))
{
return false;
}
accordion_me.accordion('activate', i);
return false;
});
});
( ), , .
, 1 , id .accordion-me, .
, html-, .. Div.accordion-me.