Sha256: 7bc58ffd8969aa252269e31c72fc400972377be6510067a11f940ad9ad473f45

Contents?: true

Size: 638 Bytes

Versions: 6

Compression:

Stored size: 638 Bytes

Contents

// Copy the value of a text input or textarea to another element.
//
// @example
// ```erb
// <%= form.translated :text_field, :example, data: { "text-copy" => true, "target" => "strong[data-copy-example]" } %>
//
// <div data-copy-example>
//   <%= t(".preview") %>
// </div>
// ```
//
window.addEventListener("DOMContentLoaded", () => {
  document.querySelectorAll("input[data-text-copy=true], textarea[data-text-copy=true]").forEach((element) => {
    element.addEventListener("change", (event) => {
      const target = document.querySelector(event.target.dataset.target);
      target.innerText = event.target.value;
    })
  });
})

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/packs/src/decidim/admin/text_copy.js
decidim-admin-0.29.0 app/packs/src/decidim/admin/text_copy.js
decidim-admin-0.29.0.rc4 app/packs/src/decidim/admin/text_copy.js
decidim-admin-0.29.0.rc3 app/packs/src/decidim/admin/text_copy.js
decidim-admin-0.29.0.rc2 app/packs/src/decidim/admin/text_copy.js
decidim-admin-0.29.0.rc1 app/packs/src/decidim/admin/text_copy.js