Mottie/tablesorter

pager widget, ajax, update never triggers on load

Closed this issue · 10 comments

I have an overlay on my site I use during loads. I used to be able to bind it to 'update' for all table sorter loads (filter, sort, and ajax requests). Since the new update and switching to the widget it no longer works on the first load anymore.

Was this intended? If so why? Before I find a new way in my code base I just wanted to check here.

I take this back, update is firing, but it's firing before filterStart. then filterStart never does an update at the end.

I thought update would always be the LAST tigger no mater what addons/widgets I'm running :\

Actually "updateComplete" should be the last event fired... I did end up changing the pager to trigger an update event to initialize widgets on load... lets see if the next update fixes this issue.

Edit: Oh the issue with the filter is that it doesn't initialize if there is no table content (empty table), which it is before the ajax call is processed, so the filter widget doesn't initialize until later. I had to work around this to get the sticky headers to work properly for issue #449.

okay, I can easily change all my code to use updateComplete as well but IIRC that wasn't the case at one point and thus it wasn't working for me. I remember I was using it at once point though. I finally got around to make your git a module of my git so that I can stay in sync better now. I didn't know I could have uncommitted changes in a module so that worked out well for me ;)

okay so I'm still trying to figure out why with using Ajax with the pager widget filterStart is fired after updateComplete

This is what I have been using it'll now which worked 100% before.

                .bind('filterStart sortStart pageMoved', function() {
                        top.loading('show');
                })
                .bind('updateComplete', function() {
                        top.loading('hide');
                })

But now filterStart fires after updateComplete which no returning updateComplete so this code no longer works. I haven't seen the update you were speaking of so sorry if it's fixed. Just wanted to document my debug someplace now that i have the columnSelector working 100% with ajax again.

okay I'm really confused now. Since I'm using ajax (via pager widget) when I goto the next page, it's does

updateComplete -> filterStart

if I had filters wouldn't that cause a loop? since filterStart would cause an other ajax call, which would cause an other updateComplete -> filterStart?

okay this is working for me

                .bind('filterStart sortStart pageMoved', function() {
                        top.loading('show');
                })
                .bind('filterEnd sortEnd', function() {
                        top.loading('hide');
                })
                .bind('updateComplete', function() {
                        // other actions (add links to items in table)
                        top.loading('hide');
                })

Since I have lots of things I run in the updateComplete that I can't have run twice I guess I have to do this in 3 binds now instead of 2.

I'm wondering if the fix from issue #449 will fix this for me, any chance you'll be making a commit soonish? not a release but at least a commit so I can test?

okay looks like I found the solution.

                .bind('filterStart sortStart pageMoved', function() {
                        top.loading('show');
                })
                .bind('updateComplete pagerInitialized', function() {
                        // other actions (add links to items in table)
                        top.loading('hide');
                })

Since pagerInitialized only fires on the initial load and updateComplete on every other update, this seems to have solved my issue.

Ok, I've updated the repo with all my latest changes.

binding to both updateComplete and pagerInitialized is still required but now that I have found it that kinda makes more sense anyhow. I'm going to close this issue as I feel it's resolved now.

Thanks Mottie.