.onRead() not firing / page not refreshing data?

I’m a newbie :slight_smile: The question is super simple, I promise. I assume I’m missing something obvious.

Basically: I have a dynamic dataset in which I have a field/boolean ’ last '. This boolean determines whether a button taking me to the next item in the dataset is shown on the page or not. If ‘last’ is “true” then the “next” button becomes hidden; if it’s “false” then (in my understanding the IF isn’t executed and therefore) the button stays visible. Just to be sure that that is the case I even added else{} . Here’s my code:

$w.onReady(() => {
$w( “#dynamicDataset” ).onReady(() => {

let last = $w( “#dynamicDataset” ).getCurrentItem().last;

//“previous” button
$w( ‘#buttonprev’ ).link = “/ch03/” + [$w( “#dynamicDataset” ).getCurrentItem().pageNumber - 1 ];

// “next” button
$w( ‘#buttonnext’ ).link = “/ch03/” + [$w( “#dynamicDataset” ).getCurrentItem().pageNumber + 1 ];

	**if**  (last ===  **true** ) { 
            		 $w( '#buttonnext' ).hide(); 
                  	  } **else** { 
          		  $w( '#buttonnext' ).show(); 
                      } 

});
});

The problem occurs when I view an item the boolean of which meets the if condition and then go to an item the boolean of which doesn’t.

When I get to the item for which “last” is “true”, the #buttonnext’ becomes hidden (as desired), but if I then try going to the previous item (by clicking the “previous” button) the #buttonnext’ will be hidden for that element, too (even though its boolean field in the dataset is set to “false”, and when I viewed that element before the #buttonnext’ was there). BUT if I refresh the page the #buttonnext’ will appear again.

Example: I’m viewing the item B, I can see 2 buttons: “previous” and “next”. I click “next”. The button takes me to the item C. The item C has “last” field set to “true” so “next” button is hidden and the only button I see on this item’s page is “previous” (good, this is what I wanted to happen.) However, if I then click “previous” and and go back to the item B, now B too has no “next” button and only the “previous” button (even though its boolean field doesn’t meet the condition for the code to execute the IF to hide the “next” button.) If I were to click “previous” again, and view the item A, it will also be missing the “next button”. If I reload the page the “next” button reappears.

The kicker: the code has worked perfectly on the actual website for the past two years, and only stopped working today. But somehow it still works perfectly in wix website editor preview? Least to say, I am super confused.

Here’s where this whole situation loses me: if let last = $w( “#dynamicDataset” ).getCurrentItem().last specifically gets data from the current item then how come that when I go to a different item the " let last" doesn’t get ‘updated’? But also it clearly DOES get updated (the “next” button disappears at appropriate moments after all, the problem is that once it happens it becomes permanent for all other items too) but why is it apparently a one way street only, from “false” to “true”?

So, what is the matter? (in simple terms please!) Thank you! <3

Hi! Can you please share your site so i can check?

Hi! The page on which the problem occurs is https://www. the-clockmaster. com/ch03/37 (this is the last item) so if you try going between items 36-37 via the buttons/arrows you can experience the problem.

Curiously, if you go to those pages via “get feedback” link ( https:// wix. to/P0BuByE and then click latest in the menu) the pages works correctly.

Hi Marcia!
This issue should be fixed for your site. Please let me know if it is okay now

@illiao It is! Thank you sm! <3