Ajax load more button

Hey there,

I was playing around with an ajax load more button today and run into a strange issue.
Im using the plain starterkit and followed all instructions from the cookbook. So far everything works fine.
I click the button and ajax loads the next 2 projects and the button disappears when no more project are there to show.

But if I add a new Project (now I have 6 in all) and I click the button again ajax loads the projects correctly but the button stays there even if all existing projects are already shown. Now I have to click the button one more time. When I check the logs, the more value is still on true. When I delete the new added Project (Now im back to 5 Projects) it’s working fine again and the button disappears. Can anyone else confirm the same issue?

I tested it with 6,7,8,9,10 Projects and I’m always getting the same issue.

Thanks in advance!

Must be an logic issue with the offset/limit pairing, I get the same issue, but only with even numbers of projects it seems.

Okay its good to know that it’s not just me :slight_smile:

I think, this line in the controller

  $more = $count > $offset + 1,

should be

  $more = $count > $offset + $limit;

but it’s too hot to think straight…

Tested this with different limits now and seems to work.

Yep works! I tried to play around with everything else than this damn 1 :smiley:

At least the weather here in Sydney is getting colder :cloud_with_rain:

1 Like

Sorry, I even have to admit to writing that recipe :see_no_evil::hear_no_evil::speak_no_evil:

Rushing to correct that now…

and even in this heat… Thanks so much @texnixe :slight_smile: