Skip to content

Commit

Permalink
Add show.blacklight.blacklight-modal and ajax:success event listeners…
Browse files Browse the repository at this point in the history
… for when the form is submitted successfully in AJAX

Find the show.blacklight.blacklight-modal in
https://github.com/projectblacklight/blacklight/blob/main/app/javascript/blacklight-frontend/modal.js#L188

Co-authored-by: Jane Sandberg <[email protected]>
Co-authored-by: Christina Chortaria <[email protected]>
  • Loading branch information
3 people committed Dec 20, 2024
1 parent 738be14 commit a4b4898
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@
//
//= require ./custom_range_limit.js
//= require ./orangelight.js

// Wait for the modal to open
document.addEventListener('show.blacklight.blacklight-modal', function () {
// Wait for the form to be submitted successfully
$('.modal_form').on('ajax:success', function () {
Blacklight.Modal.hide();
});
});
3 changes: 2 additions & 1 deletion app/views/catalog/_ask_a_question_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%= render :partial=>'shared/flash_msg' %>
<%= simple_form_for(
form,
remote: true,
url: contact_question_path,
data: { blacklight_modal: 'trigger' },
html: {class: "modal_form"}
Expand All @@ -18,7 +19,7 @@
<%= f.input :feedback_desc, as: :hidden %>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bl-dismiss="modal">Cancel</button>
<%= f.submit "Send", class: "btn btn-primary", data: {bl_dismiss: "modal"}, id: 'submit-question' %>
<%= f.submit "Send", class: "btn btn-primary", id: 'submit-question' %>
</div>
<% end %>
</div>

0 comments on commit a4b4898

Please sign in to comment.