Multiple jPages controls and 'destroy' method
vpiyanov opened this issue · 4 comments
The 'destroy' is destroying incorrect jPages control in case multiple jPages controls exist on the page.
To reproduce see: http://jsfiddle.net/HNKEz/
Change value in the first combobox and both jPages controls get broken.
Anybody find a solution to this?
...not sure if there're still people with this problem
actually the plugin didn't seem to be built to cater with multiple instances,
the only workaround I could think of and actually work, is to copy the js file and probably name it jPages2.js, and replace all instances of "jPages" to "jPagestwo" inside the new js file, go on the number line if you have more than 2, and call functions using .jPages(), jPagestwo() and so on,
please kindly let me know if there're any better ways... but this works for me - the bottom line
I wrote my own Destroy function based on what was in the plugin.
// holder == The pagination holder
// container == The container for the items to pagination
// item == The item that is being paginated through
function destroyJPages(holder, container, item) {
$(container).unbind("keydown.jPages");
$(container).unbind("mousewheel.jPages DOMMouseScroll.jPages");
$(container).css("min-height", "");
$(container+" "+item).css("display","initial");
$(holder).removeClass("animated jp-hidden jp-invisible ");
$(holder).removeClass("jp-hidden").fadeTo(0, 1);
$(holder).unbind("click.jPages").empty();
}