inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Dec 23, 2012 16:20:36 GMT -8
Hi, Would it be possible to add a callback on the pagination ? At present a plug-in relating to the posts etc only gets called on the first page view. When navigating up and down pages, using the pagination, the plug-in doesn't get called (re-run) due to it being an ajax call.
Ways I've tried to get around this have been non cross browser friendly or have messed up the search. Thanks, Pebble.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Dec 23, 2012 23:23:11 GMT -8
The widget emits a custom event ("paginationchange") so you could theoretically setup a listener for that event, something like
$('.ui-pagination').on('paginationchange.myplugin',function(evt){ //Code to execute on each page change goes here })
Note I haven't actually tested this in a plugin but I suspect it should work.
ETA: BTW Proboards also includes the livequery plugin. Perhaps one of the developers can speak to this but given the reviews I've seen on performance lags with that plugin I am reluctant to use it.
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Dec 24, 2012 5:09:55 GMT -8
Hi Eton, That actually runs the code before the ajax call , so in effect, it's running before the new page is loaded. I guess it will have to be something that runs after the search has finished (or maybe before the search starts to run but after other events). I've tried this but it then messes up the search
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Dec 24, 2012 21:57:47 GMT -8
Now that is disheartening given the promising ring to that event's name, but there is also "afterSearch" which looks to be firing from within the search complete routine via both cached and AJAX. Give this one a shot
$('.ui-autosearch').on('autosearchaftersearch',function(){ //code goes here })
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Dec 25, 2012 14:50:57 GMT -8
Ahhhh...... My first thought was 'a path already travelled which leads to a dead end' but I gave it a go anyway and it seems to have have worked! A minor adjustment or two for the first page visited but it should be good to go. I'm not sure if something has changed proboards side since I tried this. It seemed to mess up the search previously. Cheers Eton for showing me the road to salvation!
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Dec 25, 2012 17:31:23 GMT -8
Thanks for confirming, this will help avoid having to use those notoriously inefficient mutation events I can return the favor and confirm that this custom event remains unchanged (except for the removal of a comment) ever since the alpha days when it used to be called combined.js. You may already know this but for those that don't, the thing that trips up anybody new to UI (including me) is the fact that jquery UI automatically prepends the widget's namespace to the event and also lowercases it (e.g "afterSearch" becomes "autosearchaftersearch") so .on("afterSearch",func) would yield no results. I've not yet needed it in a plugin but from console testings I can see that the callback function gets passed two params, the first being an extended event object and the second an object containing both the request that initiated the AJAX call as well as the response. I ran it against the members page here on PBS for example then sorted by group/rank column and got the following(for reference) - Param 1:
{ "type": "autosearchaftersearch", "timeStamp": 1356484177901, "jQuery172014408139790271401": true, "isTrigger": true, "namespace": "", "namespace_re": null, "target": { }, "delegateTarget": { }, "currentTarget": {}, "handleObj": { "type": "autosearchaftersearch", "origType": "autosearchaftersearch", "guid": 124, "namespace": "myplugin" } } - Param 2:
{ "request": { "page": "", "filters[]": "", "q": "", "view": "", "sort": "order", "dir": "desc", "csrf_token": "yLNVzwrY" }, "response": { "page": 1, "pb_data": { "proboards.user": { "92106": { "url": "/user/92106", "name": "Ace Trainer Dom", "id": "92106" }, "62898": { "url": "/user/62898", "name": "Marty Seppy", "id": "62898" }, "5116": { "url": "/user/5116", "name": "The Architect", "id": "5116" }, "2": { "url": "/user/2", "name": "Martyn Dale", "id": "2" }, "88478": { "url": "/user/88478", "name": "Robert", "id": "88478" }, "19529": { "url": "/user/19529", "name": "Todge", "id": "19529" }, "1": { "url": "/user/1", "name": "Patrick Clinger", "id": "1" }, "31801": { "url": "/user/31801", "name": "°", "id": "31801" }, "160763": { "url": "/user/160763", "name": "Ren Rudner", "id": "160763" }, "12045": { "url": "/user/12045", "name": "Renegade", "id": "12045" }, "125138": { "url": "/user/125138", "name": "W<>K", "id": "125138" }, "156500": { "url": "/user/156500", "name": "Kami", "id": "156500" }, "29252": { "url": "/user/29252", "name": "Derek シ", "id": "29252" }, "136400": { "url": "/user/136400", "name": "Trill ? (V5designs)", "id": "136400" }, "110769": { "url": "/user/110769", "name": "tumbleweed", "id": "110769" }, "141494": { "url": "/user/141494", "name": "Andrea", "id": "141494" }, "136705": { "url": "/user/136705", "name": "rchelitalk", "id": "136705" }, "9181": { "url": "/user/9181", "name": "The Banjo", "id": "9181" }, "66829": { "url": "/user/66829", "name": "Hero", "id": "66829" }, "145211": { "url": "/user/145211", "name": "SpiderMike™", "id": "145211" }, "164921": { "url": "/user/164921", "name": "Tim Camara", "id": "164921" }, "135834": { "url": "/user/135834", "name": "Mr. Spartan", "id": "135834" }, "143665": { "url": "/user/143665", "name": "wildgoosespeeder", "id": "143665" }, "137695": { "url": "/user/137695", "name": "Søren", "id": "137695" }, "37132": { "url": "/user/37132", "name": "Ref107", "id": "37132" }, "16715": { "url": "/user/16715", "name": "Patrick [ASE]", "id": "16715" }, "23506": { "url": "/user/23506", "name": "James [a_leon]", "id": "23506" }, "6274": { "url": "/user/6274", "name": "Suicide Guy", "id": "6274" }, "186408": { "url": "/user/186408", "name": "Keith Rozett", "id": "186408" }, "14306": { "url": "/user/14306", "name": "Jordan", "id": "14306" }, "154778": { "url": "/user/154778", "name": "Michael Stone", "id": "154778" }, "31521": { "url": "/user/31521", "name": "Trublu", "id": "31521" }, "154044": { "url": "/user/154044", "name": "Phaelyn", "id": "154044" }, "2445": { "url": "/user/2445", "name": "JayWF", "id": "2445" }, "77753": { "url": "/user/77753", "name": "Bob", "id": "77753" }, "19159": { "url": "/user/19159", "name": "**hp", "id": "19159" }, "3": { "url": "/user/3", "name": "Ryan Roos", "id": "3" }, "170108": { "url": "/user/170108", "name": "Michael Hill", "id": "170108" }, "162752": { "url": "/user/162752", "name": "Pebble", "id": "162752" }, "153968": { "url": "/user/153968", "name": "Thesealion", "id": "153968" }, "181912": { "url": "/user/181912", "name": "Ricky Zyvoloski", "id": "181912" }, "126470": { "url": "/user/126470", "name": "–", "id": "126470" }, "1515": { "url": "/user/1515", "name": "snap2000", "id": "1515" }, "16464": { "url": "/user/16464", "name": "Paul", "id": "16464" }, "29575": { "url": "/user/29575", "name": "dodz", "id": "29575" }, "33409": { "url": "/user/33409", "name": "Brian Ordonez", "id": "33409" }, "164687": { "url": "/user/164687", "name": "Vinh", "id": "164687" }, "49511": { "url": "/user/49511", "name": "Anselm", "id": "49511" }, "12218": { "url": "/user/12218", "name": "woop", "id": "12218" }, "42712": { "url": "/user/42712", "name": "♫Sossity♪", "id": "42712" } } }, "limit": 50, "total": "184874", "content_score": 500, "results": "\n\t<tr id=\"member-181912\" class=\"member item first clickable\">\n\t\t<td class=\"checkbox clickable\"><input type=\"checkbox\" class=\"list-item-checkbox\" /></td>...[snip]" } }
Also from my initial tests it appears the event fires on initial page load if there are multiple pages but not on single page displays. Further observations would be helpful and could be posted in this thread for reference so others may benefit.
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Dec 26, 2012 5:16:32 GMT -8
Cheers for the info Eton. I've just had a quick play about with it and it seems that in FF it does fire on a 'single' page load but not with IE (at least for me that is what is happening). A page load with 'multiple pages' seems to work fine in all browsers. I was hoping to avoid IE checks with V5 but (thinking aloud) maybe a check for IE and on the pagination content would be a work around
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Dec 28, 2012 16:57:22 GMT -8
Just an update: I've now got a plug-in working on all pages (with and without pagination & in IE, FF, GC) and I've given it a couple of people to test. If they confirm it's working then I'll post it up here. It may not work for all plug-ins but it's a start (and it's a bit ugly, but I'll sort that out once I know it's working)
I still think it would be better if something on the backend was done to allow certain plug-ins to fire after pagination/search via a callback or ........
|
|