You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I would like to create a modal form where the formURL is dynamically defined according to the selected row in a table.
I was able to load the form dynamically as follows.
$("#create-btn").on("click", function() {
var formURL = get_url(); // Get the form URL based on the selected table row.
$('#modal').find('.modal-content').load(formURL, function () {
$('#modal').find('.modal-content form').attr("action", formURL);
$('#modal').modal("show");
});
});
But this way, event handlers are not added, as they are when function modalForm is called, and when the form is submitted and any ValidationError is raised, the browser redirects to the modal's template as follow.
I understand that I have to add the event handlers on the modal for them to stay even after errors, but I don't know how to do it. So, is there any way I'm not seeing to dynamically define the formURL or add the events after loading the form?
As I'm kind new to Django itself, there's a better way to achieve this behavior?
Thanks!
Gláucio
The text was updated successfully, but these errors were encountered:
Hello, I would like to create a modal form where the formURL is dynamically defined according to the selected row in a table.
I was able to load the form dynamically as follows.
But this way, event handlers are not added, as they are when function modalForm is called, and when the form is submitted and any ValidationError is raised, the browser redirects to the modal's template as follow.
I understand that I have to add the event handlers on the modal for them to stay even after errors, but I don't know how to do it. So, is there any way I'm not seeing to dynamically define the formURL or add the events after loading the form?
As I'm kind new to Django itself, there's a better way to achieve this behavior?
Thanks!
Gláucio
The text was updated successfully, but these errors were encountered: