Hi,

After updating in 8.x-1.4, infinite scroll on click stop working due to javascript error :
'view is undefined'

On my view container, I have multiple classes like that :
<section class="js-view-dom-id-b89cec43e1556f9222a1be13111c8002ac4e0fee743168d79bd4eba6c8cf63c4 _up _down">

And the javascript selector does not take that in account, it get all classes :
infinite-scroll.js => line 29.
var currentViewId = this.attr('class').replace(/(.*)js-view-dom-id-/, 'views_dom_id:');

So the 'currentViewId' become 'views_dom_id:b89cec43e1556f9222a1be13111c8002ac4e0fee743168d79bd4eba6c8cf63c4 _up _down', and then, it's an undefined view.

I've fixed the code with this :

    var regexp = /(js-view-dom-id-\w+)/;
    var matches = regexp.exec(this.attr('class'));

    // var currentViewId = this.attr('class').replace(/.*js-view-dom-id-(\w+).*/, 'views_dom_id:');
    var currentViewId = matches[1].replace(/js-view-dom-id-/, 'views_dom_id:');

But it can be much more improved.

Thanks for reading.

Comments

bend25 created an issue. See original summary.

bend25’s picture

Issue summary: View changes
sam152’s picture

Good catch. Are you able to submit a patch with this fix in it?

https://www.drupal.org/patch/submit

bend25’s picture

Here is the patch.
First time doing it, tell me if anything is wrong.

sam152’s picture

Status: Active » Needs review
sam152’s picture

Looks great, thanks.

  • Sam152 committed 656584e on 8.x-1.x authored by bend25
    Issue #2903086 by bend25: view is undefined (Javascript) because view...
sam152’s picture

Status: Needs review » Fixed

Fixed, will cut a new release to prevent this from breaking any other sites.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Dency Mary A’s picture

#4 Working, Thanks...