Sha256: 14acdd284f6c85979a6459d82d2d8e787775da660d82bd697c61152166b6fb3b
Contents?: true
Size: 1.38 KB
Versions: 26
Compression:
Stored size: 1.38 KB
Contents
<%= pb_form_with(scope: :example, url: "", method: :get, loading: true) do |form| %> <%= form.text_field :example_text_field_loading, props: { label: true } %> <%= form.actions do |action| %> <%= action.submit %> <%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %> <% end %> <% end %> <script> const loadingForm = document.querySelector(".pb_form_loading") if (loadingForm) { loadingForm.addEventListener("submit", function(event) { event.preventDefault(); const submitButton = event['submitter']; const cancelButton = event['target'].querySelector('button[type="reset"]'); if (submitButton) { let currentClass = submitButton.className; let newClass = currentClass.replace("_disabled_loading", "_enabled"); let cancelClass = cancelButton ? cancelButton.className : ""; let newCancelClass = cancelClass.replace("_disabled", "_enabled"); setTimeout(function() { submitButton.disabled = false; submitButton.className = currentClass; if (cancelButton) { cancelButton.disabled = false; cancelButton.className = cancelClass; } }, 5000); } }); } </script>
Version data entries
26 entries across 26 versions & 2 rubygems