metafizzy / infinite-scroll

📜 Automatically add next page
https://infinite-scroll.com
7.41k stars 1.74k forks source link

Rating of a topic and infinite scroll #981

Closed madromas closed 3 months ago

madromas commented 7 months ago

After new batch of topics load up, my rating of a topics stops working. How do I initialize a function every time it loads more topics?

icms.rating.onDocumentReady();

Where do I place it, so it will run every time infinite scroll loads more topics?

madromas commented 7 months ago

Fancybox for gallery also stops working after new topics load. How to reinitialize that?

ac-mmi commented 3 months ago

for initializing a function every time it loads more topics you should add the functionality in the method defined for the path attribute of infinite scroll

madromas commented 3 months ago

for initializing a function every time it loads more topics you should add the functionality in the method defined for the path attribute of infinite scroll

This didn't help at all....

ac-mmi commented 3 months ago

need code to understand better

madromas commented 3 months ago

icms.rating.onDocumentReady();

I have presented it above.

Here is what I did:

  history: false,
  scrollThreshold: 500,
});
$('.content_list').one('click', function(){
      icms.rating.onDocumentReady();
    }); 

Everything works. but, there is this extra click I have to do. Lets say I want to vote up, I have to click arrow twice for it to log the vote. And same with every post.

ac-mmi commented 3 months ago

you are using this infinite scroll in the conversations list page

madromas commented 3 months ago

No, on the post list page here glonks.com

ac-mmi commented 3 months ago

Reason for your vote-up not working is that your event a.vote-up.click won't work for dynamically generated elements in order to rectify that you should use $(document).on('click', 'a.vote-up', function(){ //function defintion }); It allows you to attach an event handler to a parent element that is always present (like document).

madromas commented 3 months ago

What about on vote-down?

You see here. I appreciate the help, but I fail to understand.

Like this?

$(document).on('click', 'a.vote-up', function(){  
icms.rating.onDocumentReady();
});

$(document).on('click', 'a.vote-down', function(){  
icms.rating.onDocumentReady();
});
ac-mmi commented 3 months ago

Yes,The reason is that when you load more posts, the click event isn't bound to the newly generated vote-up/down buttons. By using $(document).on,the document is searched for the vote-up/down button every time it gets clicked, thereby binding the event dynamically to both existing and newly added buttons.

madromas commented 3 months ago

It works good. Only one tiny issue. Is there a way to make that one extra click to disappear?

Example: When new row of topics load up and you try to vote-up or vote-down, you have to click it twice the first time for it to register a vote. Like in order for vote system to work one extra click has to be made... Not a big deal, just wondering.

ac-mmi commented 3 months ago

Maybe remove the function from rating.js that might be causing the problem.

Also one question i saw your esoTalk-v3 there i tried to change the default.master.php file from core/views but the same weren't reflected in the browser

madromas commented 3 months ago

Also, on the new posts that loads, the pictures become not clickable anymore.....

esoTalk-v3 there i tried to change the default.master.php file from core/views

Let me take a look, refresh my memory. What are you trying to do there?

madromas commented 3 months ago

The only reason why changes will not update in the browser is if you placed a JS code that has errors in it.

ac-mmi commented 3 months ago

when loading new images there is this one class .ajax-modal-ready missing that might not opening the modal Cause i tried to add this class in the newly loaded post and it worked Something in the backend you need to correct while rendering

madromas commented 3 months ago

That's the thing. Modal loads in the beginning when site loads, Than when new posts load, modal is missing. Gotta include that modal in there somehow. No big deal, I will try to figure it out....

And If I were you, I would not use that EsoTalk. There is an error there, that I cannot figure out, and it will only work on 8.1. I think some tables not installing during installation. Anyway its a headache.

madromas commented 3 months ago

I fixed the missing .ajax-modal-ready , they open fine, just not in MODAL window... uuugggghhh

Need to load modal.js upon new post load. But that's not important....

Thank you for your help

ac-mmi commented 3 months ago

Could you please close this issue? It would be helpful for me as I am new to this platform.

madromas commented 3 months ago

Could you please close this issue? It would be helpful for me as I am new to this platform.

In esoTalk, change this line to FALSE

https://github.com/madromas/esoTalk-v3/commit/39ed584726878ac1641f02a6228bfae1e822f34f

SO it will look like this:

$config["esoTalk.aggregateCSS"] = false; $config["esoTalk.aggregateJS"] = false;

Let me know if it works. I will close this issue...

madromas commented 3 months ago

Could you please close this issue? It would be helpful for me as I am new to this platform.

I just checked EsoTalk and everything now working

And to edit default.master. Each Skin has it's own default master here:

addons/skins/Dark/views/default.master.php

If you have any questions, let me know. I'm closing this issue....