views:

508

answers:

2

Hi everyone -

I basically have a rebinding issue but none of the solutions I've found has specified how to remove a binding entirely (and for a plugin-based function, not like unbind("click")).

For the SimplePager plugin, basically it adds a cool pager element at the bottom of the page, but I lose the AJAX binding after I perform a separate function (specifically a "flip").

The original binding is through:

$("ul.paging").quickPager({pageSize:6});

But when I try to do that same thing after the flip, I get two paging elements.

So I figured, fine, I'll clean the slate and remove all the bindings and readd it, kinda like:

$("ul.paging").unbind(quickPager) <-- this didn't work.

How would I do that, and is there a better way to go about it?

Thanks!

A: 

Looks like if you just look for the UL with class pageNav and remove it, the added DOM elements should be deleted. You might also want to remove any pageN clases from your DOM elements. Then you should be able to reapply the plugin.

Note: this is based on just a cursory examination of the posted plugin code. YMMV.

$('.pageNav').remove();
$('ul.paging').children('[class^=page]').each( function() {
    var $this = $(this);
    var newClass = $this.attr('class').replace(/page\d+/,'');
    $this.attr('class',newClass);
});
$("ul.paging").quickPager({pageSize:6});

I think, though, that I'd explore why the "flip" function is breaking the plugin. Perhaps, it's cloning things and the handlers are getting removed. I think making it so your other function doesn't break the plugin is a better way to handle it, but without the code for that there's not much help I can give you.

tvanfosson
A: 

Do you have a link to the code you're using, or a test page? I wrote the simplepager plugin so I'd like to see where it is breaking/being broken and perhaps make any necessary amends.

P.s. There is also an update to the plugin posted at http://www.geckonewmedia.com/blog/2009/8/20/simplepager---jquery-paging-plugin--updated

Dan Drayne