app/javascript/beyond_canvas/initializers/inputs.js in beyond_canvas-0.22.0.pre vs app/javascript/beyond_canvas/initializers/inputs.js in beyond_canvas-0.23.0.pre
- old
+ new
@@ -1,17 +1,17 @@
(function ($) {
const onDOMReady = function () {
$('input[type="file"]').each(function () {
- var $input = $(this),
+ const $input = $(this),
$label = $(`.input__file__text.${$input.attr('id')}`),
labelVal = $label.html();
$input.on('change', function (e) {
- var fileName = '';
+ let fileName = '';
if (this.files && this.files.length > 1)
- fileName = (this.getAttribute('data-multiple-caption') || '').replace(
+ fileName = (this.getAttribute('data-multiple-caption') || '{count} files selected').replace(
'{count}',
this.files.length
);
else if (e.target.value) fileName = e.target.value.split('\\').pop();
@@ -31,7 +31,12 @@
$input.removeClass('has-focus');
});
});
};
- $(document).on('ready page:load turbolinks:load', onDOMReady);
+ $(document).on('ready page:load turbolinks:load', () => {
+ const observer = new MutationObserver(() => onDOMReady());
+
+ onDOMReady();
+ observer.observe(document.body, { childList: true, subtree: true });
+ });
})(jQuery);