inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on May 23, 2020 8:20:23 GMT -8
Peter, Chris, Todge - or anyone else who knows ... The Scavenger Hunt plugin utilizes proboards.on('pageChange, function()) (see snippet below) but I have someone who's telling me that there's an issue on pages with pagination and using pagination [1][2]. Here's part of the code that handles pageChange: //On page load, run code with default odds var oddsModifierNumber = frequency; rollTheDice(oddsModifierNumber);
//On page change event, rerun code proboards.on('pageChange', function() {
//Reset everything $('.prizeContainer, .prizeDetector').remove(); unbindFunctions(); bindFunctions();
//Halve odds, because changing pages is easy oddsModifierNumber = frequency * 2; rollTheDice(oddsModifierNumber); });
If you need to see the entire code, you can find it on GitHub [3]. The snippet above starts on line 419. Thanks for any help!
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,324
January 2004
todge
|
Post by Todge on May 23, 2020 16:21:18 GMT -8
The only thing that I can see that may cause an issue is this part... //Reset everything $('.prizeContainer, .prizeDetector').remove(); unbindFunctions(); bindFunctions(); $('.prizeContainer, .prizeDetector').remove(); is removing cell with the classname 'prizeDetector', but then the unBindFunctions and the bindFunctions functions are both trying to access that same cell, which no longer exists... Maybe try moving the two functions above the remove() instruction?
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on May 25, 2020 2:54:54 GMT -8
A few things I can see from looking at the code. - First prize will result in NaN because incrementNum has an undefined value.
Cast it to a number before adding. You seem to do this a few times later on after setting the text in the mini profile, so restructure that a little to stop duplicating code. This is not the cause of the pagination issue, just something I spotted.
- prizeBagNumber appears to come from the mini profile value and added to incrementNum. This is getting updated before and after, so this is why the amount is incorrect when on page change.
1. A better way would be to store key values for all users on the page in a table (map), and do the update in one location, that way you know it will be accurate. 2. Another way would be to query the key each time instead of pulling from the mini profile. I prefer #1, but this works fine and might be easier to implement.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on May 25, 2020 5:00:48 GMT -8
Thank you both, Todge and Peter! I'll work on this when I get back home Wed. I very much appreciate you both taking the time to look at this!
|
|