Rate widget not working with comments ajax loadmore

Created on 17 May 2022, almost 3 years ago
Updated 9 September 2024, 6 months ago

Problem/Motivation

We are using the rate modules as a like function on comments, The comments are ajaxified with "load more" also ajaxified, When we use ajax pager on comments then the rate widget works good on first page load, But as soon as we click on load more and new comments are loaded then rate widget does not work on newly loaded comments

Steps to reproduce

  • Create rate widget for like
  • attach rate widget to the comments
  • enable the ajax pager on comments and set some page limit
  • Go to page where comments are displayed
  • click on load more
  • click any rate widget on newly loaded comments,
🐛 Bug report
Status

Postponed: needs info

Version

3.0

Component

Code

Created by

🇮🇳India kaustubhb Mumbai

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I have a site that is using Views Infinite Scroll module, and the view has the Rate module used to present a thumbs-up "Like" rating for nodes in the view. After the user scrolls past several nodes and more content is loaded via AJAX, the Rate liking stops working, so in our experience the Rate module is not compatible when AJAX is used in a view.

    I have changed the view to use a pager in the short term, and we're looking at creating some custom javascript/JQuery event listener to overcome the problem with Rate not being compatible with AJAX.

  • 🇦🇹Austria jordik

    Can you please test if it works with the LazyBuilder Use Lazy Builders to build widget form Needs work ?

  • 🇦🇹Austria jordik

    And can you please share more info about your setup and steps to reproduce? Error logs etc.?

  • 🇳🇱Netherlands falco010 🇳🇱 The Netherlands

    Hi all, we are having the same issue.

    This is the console log error we get:

    "
    An AJAX HTTP error occurred.
    HTTP Result Code: 404
    Debugging information follows.
    Path: /views/ajax?page=1&ajax_form=1
    StatusText: Not Found
    ResponseText: {"message":""}"
    

    @JordiK I tried if it works with https://www.drupal.org/project/rate/issues/3283891 Use Lazy Builders to build widget form Needs work but unfortunately, that does not fix the issue.

  • 🇳🇱Netherlands falco010 🇳🇱 The Netherlands
  • 🇳🇱Netherlands falco010 🇳🇱 The Netherlands
  • Tested. Cannot apply Patch#6 and MR !7 in Use Lazy Builders to build widget form Needs work .
    It didn!t work. Tested versions 3.1.0 and 3.0.x-dev

  • 🇺🇸United States Mirakolous

    Line 266 of RateWidgetField seems to be where the issue lies.

    I just removed these lines to get it working for me (I don't need the views portion of this widget)

          // Mark the widget being part of a view and add the view url.
          $widget->set('isViewsField', TRUE);
          if (is_null($widget->get('viewsUrl'))) {
            if ($this->view->hasUrl()) {
              $widget->set('viewsUrl', $this->view->getUrl());
            }
          }
Production build 0.71.5 2024