Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroy.pager appears broken #980

Closed
meatheadmike opened this issue Jul 30, 2015 · 2 comments
Closed

destroy.pager appears broken #980

meatheadmike opened this issue Jul 30, 2015 · 2 comments

Comments

@meatheadmike
Copy link

Maybe I'm doing something wrong here, but no matter how I call destroy pager it seems to "keep on trucking" regardless. The example show here doesn't seem to work either:

https://mottie.github.io/tablesorter/docs/example-pager.html

If I click on "destroy" I can click next page, add rows, etc. It all works still.

@Mottie
Copy link
Owner

Mottie commented Jul 30, 2015

Hi @meatheadmike!

Ahh, it looks like I broke it when I added unique pager namespaces in dd80e3c.

For now, you can still enable, disable and destroy the pager, but you'll need to get and use the namespace first (demo).

var pagerOptions = {},
    $table = $('table');

$('.enable').click(function () {
    var $this = $(this),
        namespace = $table[0].config.namespace + 'pager',
        state = $this.text(),
        newState = state === 'Enable' ? 'Disable' : 'Enable';
    $table.trigger(state.toLowerCase() + namespace);
    $this.text(newState);
});

$('.destroy').click(function () {
    var $this = $(this),
        namespace = $table[0].config.namespace + 'pager';
    if (/Destroy/.test($this.text())) {
        $table.trigger('destroy' + namespace);
        $this.text('Restore Pager');
    } else {
        $table.tablesorterPager(pagerOptions);
        $this.text('Destroy Pager');
    }
    return false;
});

I'll probably end up renaming the events to "enablePager", "disablePager" and "destroyPager" without needing the namespace.

@meatheadmike
Copy link
Author

Now that's what I call efficiency! Thank you sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants