[英]jQuery Accordion - doesn't collapse
執行分頁時; 在第二頁上的標題不會折疊。 我該如何解決? 我使用了可折疊的屬性,並將其設置為true,但這沒有用。 有任何想法嗎? JSFiddle
var paginatorHandle = null;
jQuery.fn.extend({
paginateAccordion: function (options) {
var currentPage = options.currentPage ?parseInt(options.currentPage, 10) : 0;
var itemsPerPage = options.itemsPerPage ? parseInt(options.itemsPerPage, 10) : 5;
var paginatorControl = options.paginatorControl;
return new AccordionPaginator(this, currentPage, itemsPerPage, paginatorControl);
}
});
jQuery(document).ready(function () {
jQuery("#dalist").accordion({
autoHeight: false
});
paginatorHandle = jQuery("#dalist").paginateAccordion({
"currentPage": 0,
"itemsPerPage": 3,
"paginatorControl": jQuery("#accordionPaginator")
});
// initial paginate call
paginatorHandle.paginate();
jQuery("#accordionPaginator .nextPage").click(function () {
paginatorHandle.nextPage();
});
jQuery("#accordionPaginator .previousPage").click(function () {
paginatorHandle.previousPage();
});
jQuery("#accordionPaginator .goToPage").change(function () {
var pageIndex = parseInt($(this).val(), 10);
paginatorHandle.goToPage(pageIndex);
});
});
//this is the main class
function AccordionPaginator(element, currentPage, itemsPerPage, paginatorControl) {
this.element = element;
this.currentPage = currentPage;
this.itemsPerPage = itemsPerPage;
this.paginatorControl = paginatorControl;
// does the actual pagination (shows/hides items)
this.paginate = function () {
var index = this.currentPage * this.itemsPerPage;
element.accordion("option","activate", index);
element.children().hide();
if (index < 0) {
this.element.children("div:first").show();
this.element.children("h3:first").show();
} else {
this.element.children("div:eq(" + index + ")")
.show();
this.element.children("h3:eq(" + index + "),h3:gt(" + index + ")")
.filter(":lt(" + this.itemsPerPage + ")")
.show();
}
this.refreshControl();
};
有人可以幫我嗎?
對不起,我遲到了-我不在
通常,在這種情況下,簡單的解決方案是這樣的:
// make a function with the scipt/plugin/code that
// you need to execute repeatedly
function doSomething(param1, param2)
{
// execute some code, usualy some plugin
// like open modals, run ajax queries, make tables sortable
// something that needs to be executed lots of times in a page
// especially after another plugin is executed
}
// then call your custom function inside your plugin's callback OR success
$(selector).pluginFunction({
option1: "data1",
option2: "data2",
on_callback_function({
doSomething(param1, param2)
})
})
現在,我不知道您的插件如何正常工作,但是,如果您的插件支持回調/成功,則您可以應用上述邏輯。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.