Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

onpage function-call triggers twice #42

Open
q4z1 opened this issue Jun 27, 2016 · 1 comment
Open

onpage function-call triggers twice #42

q4z1 opened this issue Jun 27, 2016 · 1 comment

Comments

@q4z1
Copy link

q4z1 commented Jun 27, 2016

Using the following code triggers the onpage function-call twice when clicking a pagination link (workaround is included):

var page = 1; // global variable
$('.sbpagination').bootpag({
total: Math.ceil(numPosts / 50),
maxVisible: 3,
firstLastUse: true,
}).on("page", function(event, p){
// @xxx: bug in bootpag? - small workaround in order to avoid double requests and refresh-timeouts
if(page == p){
return;
}
page = p;
refreshShoutbox(((p-1)*50), 50); // $.post() is called inside this function which updates the content
});

@q4z1 q4z1 changed the title onpage function-call triggered twice onpage function-call triggers twices Jun 27, 2016
@q4z1 q4z1 changed the title onpage function-call triggers twices onpage function-call triggers twice Jun 27, 2016
@gtrbarbarian
Copy link

gtrbarbarian commented Aug 30, 2016

I ran into this as well. The strange thing is that the jquery trigger (line 173) is only called once (indicating to me, that -bootpag- is working correctly), but the number of calls to the callback bound to the 'page' event seems to be doubling every time a 'page' event is triggered. i.e. on the first page, 1 call, on the 2nd page 2 calls, on the 3rd page 4 calls..then 8 , 16 ,32 ,64 (calls of the callback function). Looking at the posts in the net window in firebug, it is always multiples of the same page number being requested, which is why q4z1's workaround works (immediate return from callback on duplicate page request). This seems like a bug in the jquery event code, not the bootpag code (as evidenced by only one call to 'page' trigger.) I tried adding an unbind() to the trigger line to see if old event bindings were the culprit, but no dice.

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

No branches or pull requests

2 participants