diff --git a/app/assets/javascripts/base.js b/app/assets/javascripts/base.js index fc38d4a9..3e39eed3 100644 --- a/app/assets/javascripts/base.js +++ b/app/assets/javascripts/base.js @@ -20,17 +20,10 @@ $.fn.isPresent = function() { $.fn.scrollTo = function(selector) { $(this).animate({ - scrollTop: $(selector).offset().top - $(this).offset().top + $(this).scrollTop() + scrollTop: $(document.querySelector(selector)).offset().top - $(this).offset().top + $(this).scrollTop() }, ANIMATION_DURATION); }; -// Same as $.replaceWith, just returns the new element instead of the deleted one -$.fn.replaceWithAndReturnNewElement = function(a) { - const $a = $(a); - this.replaceWith($a); - return $a; -}; - // Disable the use of web workers for JStree due to JS error // See https://github.com/vakata/jstree/issues/1717 for details $.jstree.defaults.core.worker = false; diff --git a/app/assets/javascripts/channels/la_exercises.js b/app/assets/javascripts/channels/la_exercises.js index 13c127ee..1f47c552 100644 --- a/app/assets/javascripts/channels/la_exercises.js +++ b/app/assets/javascripts/channels/la_exercises.js @@ -42,7 +42,9 @@ $(document).on('turbolinks:load', function() { if ($row.length === 0) { $row = $($('#posted_rfcs')[0].insertRow(0)); } - $row = $row.replaceWithAndReturnNewElement(data.html); + const $html = $(data.html); + $row.replaceWith($html); + $row = $html; $row.find('time').timeago(); addClickEventToRfCEntry($row); }