Skip to content

Commit 5cebbbb

Browse files
committed
Fix tess-expandable behaviour when multiple under the same parent element. Fixes #1231
1 parent 2e11d87 commit 5cebbbb

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

app/assets/javascripts/application.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,17 @@ document.addEventListener("turbolinks:load", function(e) {
286286
this.dataset.origHeight = this.clientHeight;
287287
this.style.maxHeight = '' + limit + 'px';
288288
this.classList.add('tess-expandable-closed');
289-
var btn = $('<a href="#" class="tess-expandable-btn">Show more</a>');
289+
const btn = $('<a href="#" class="tess-expandable-btn">Show more</a>');
290+
btn[0].expandableTarget = this;
290291
btn.insertAfter($(this));
291292
}
292293
});
293294

294295
$(document).on('click', '.tess-expandable-btn', function (event) {
295296
event.preventDefault();
296-
var div = this.parentElement.querySelector('.tess-expandable');
297-
var maxHeight = parseInt(div.dataset.origHeight) + 80;
298-
var limit = parseInt(div.dataset.heightLimit || "300");
297+
const div = this.expandableTarget;
298+
const maxHeight = parseInt(div.dataset.origHeight) + 80;
299+
const limit = parseInt(div.dataset.heightLimit || "300");
299300

300301
if (div.classList.contains('tess-expandable-closed')) {
301302
div.classList.add('tess-expandable-open');

0 commit comments

Comments
 (0)