开发者

Canceling jQuery UI Accordion sections opening

I use jQuery UI accordion widget, and I wonder if it is possible to cancel opening action using accordion's changestart event. From documentation:

// This event is triggered every time the accordion starts to change.
$( ".selector" ).accordion({
   changestart: function(event, ui) { ... }
});

And event contains result开发者_如何学编程 attribute. I guess I can use this attribute to cancel event, but what value I have to use? And if it's the wrong way, how I can accomplish it another way?


You could just load the content on the create event...this would load the data into the div when the accordion is created.

$('.selector').accordion({
    create : function(event,ui) {
        $('.some-div').load('/path/to/data');
    }
});

or you could probably load the content on page load before you make the accordion

$('.some-div').load('path/to/data');
$('.selector').accordion();

or you could send the whole html over and then make it an accordion

$('.selector').load('path/to/data').accordion();

in any case, if you need to refresh the data periodically, then load the div contents on load at some point, and setup a timeout to load the new data.

$(function() {
    $('.selector').accordion();

    //Update every minute
    (function updateDiv() {
        $('.some-div').load('path/to/data');
        setTimeout(updateDiv,60000);
    })();
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜