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

pagerComplete fires twice with ajax pager #291

Closed
patriciavandermeer opened this issue May 2, 2013 · 3 comments
Closed

pagerComplete fires twice with ajax pager #291

patriciavandermeer opened this issue May 2, 2013 · 3 comments
Labels

Comments

@patriciavandermeer
Copy link

I have a table set up, with a custom pagerComplete handler(that wires a bunch of stuff up in the rows). It is being fired twice each time the table is sortered, paged, or anything that requires it to fetch the table. Once just after the ajax call is made, and once after it is complete.

I know it's firing twice, because I have console.log() statements in the handler.

Here is my trimmed down sorter code:

$('#MyTable').tablesorter(
        { headers: {
            0: { sorter: 'iso8601date' },
            4: { sorter: false },
            5: { sorter: false }
            },
            textExtraction: {
                0: customextractorfunction
            },
        })
    .bind('pagerInitialized', function (e, c) {
            console.log('pager initialize');//also a call to wire up the first page
        })
    .tablesorterPager(
        { container: $("#pager"),
            output: '{page} / {totalPages}',
            ajaxUrl: "myurl",
            page: 0,
            customAjaxUrl: function (table, url) {
                //a bunch of url processing code
                return url;
            },
            ajaxProcessing: function (data) {
            //a whole bunch of code goes here                  }
        })
    .bind('pagerComplete', function (e, c) {
                console.log("page complete callback");
                //also a call to wire up the page
    });

This isn't a huge problem, b/c it's not a lot of processes, but it also runs the creating of the cache and everything else twice, which may be more problematic, especially with large pages.

@Mottie
Copy link
Owner

Mottie commented May 2, 2013

Hi @patriciavandermeer!

I'll try to take some time looking into this issue this weekend.

I don't see it in the code above, but because I want to make sure, you're not using the filter widget - I see the extra comma after the textExtraction function, so I guess it could have been shortened for posting here?

Also, just so you know that in the next update, I plan on making it optional for the ajaxProcessing function to return parameters; so you then have the option of building the table yourself within that function and include any extra wiring up yourself. Then you won't need to bind to the pagerComplete callback to make additional changes.

@patriciavandermeer
Copy link
Author

oops! Got a little over zealous with my cutting out the excess, I have this:

sortList: [[0, 0]]

after the text extractor.

no filtering through the tablesorter plugin.

My processing isn't to complex, it's more the caching and everything that tablesorter does that is concerning. It's updating the cache, and redrawing the table twice. (I turned debug on to see this).

would a screenshot or copy paste of what ends up in the debug log be helpful?

@Mottie
Copy link
Owner

Mottie commented May 6, 2013

Hi @patriciavandermeer!

That isn't necessary, I've isolated the problem :)

Next update should be done soon... (later today or tomorrow, hopefully).

@Mottie Mottie closed this as completed in 800d602 May 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants