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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2903086-allow-view-container-with-multiple-classes-1.patch | 800 bytes | bend25 |
Comments
Comment #2
bend25 commentedComment #3
sam152 commentedGood catch. Are you able to submit a patch with this fix in it?
https://www.drupal.org/patch/submit
Comment #4
bend25 commentedHere is the patch.
First time doing it, tell me if anything is wrong.
Comment #5
sam152 commentedComment #6
sam152 commentedLooks great, thanks.
Comment #8
sam152 commentedFixed, will cut a new release to prevent this from breaking any other sites.
Comment #10
Dency Mary A#4 Working, Thanks...