In the snippet below, $modal is undefined because there are multiple form instances.
<script type="text/javascript">
$(document).ready(function() {
var $modals = $(".update-form");
var $form = $("#program-update-form-{{ form.instance.uuid }}");
$modals.on("hide.bs.modal", function() {
$form.trigger("reset");
});
});
</script>
<html>
{% for id in form.instance.uuid %}
<div id="program-update-modal-{{ form.instance.uuid }}" class="update-form">
{% endfor %}
</html>
I think what I'm wanting to do is here is gather all program-update-modals and trigger a reset on the hide.bs.modal action. The number of form instances is going to be dynamic and obviously the uuid's will be dynamic so I need to know how in jQuery to just grab all the div id's beginning with 'program-update-modal-'. Open to other suggestions as well.
$modal.on(...)binds the event handler onto the element. If you change the selector to a class selector, i.e.$(".some-class")it should bind the event to each of the elements.