[英]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.