-
Notifications
You must be signed in to change notification settings - Fork 141
Closed
Labels
Q&AQuestions and answersQuestions and answers
Description
Hi there,
This package is great and has really helped, but I was having some issues, trying to use it with async. Creating objects works gret and is no issue at all, however, by updating and deleting seem to have trouble. Delete works, but it reloads the page (so it's not async), and neither edit nor delete work after I've added a new object. I'm not entirely clear on how addModalFormFunction
works when it would need to initialize both an update and delete button.
I've made some guesses based on the demo and the docs, but there's likely just some confusion about how it all works together.
So far I have this:
function addAttachmentModalForm() {
$(".add-attachment").each(function () {
$(this).modalForm({
modalID: "#create-modal",
formURL: "{% url 'citizen_attachment_add' form.instance.pk %}",
asyncUpdate: true,
asyncSettings: {
closeOnSubmit: true,
successMessage: "Added.",
dataUrl: "LIST URL",
dataElementId: "#attachments-container",
dataKey: "list",
addModalFormFunction: updateAttachmentModalForm,
}
});
});
}
addAttachmentModalForm();
function updateAttachmentModalForm() {
$(".update-attachment").each(function () {
$(this).modalForm({
formURL: $(this).data("form-url"),
modalID: "#create-modal",
asyncUpdate: true,
asyncSettings: {
closeOnSubmit: true,
successMessage: "Updated.",
dataUrl: "LIST URL",
dataElementId: "#attachments-container",
dataKey: "list",
addModalFormFunction: updateAttachmentModalForm,
}
});
});
}
function deleteAttachmentModalForm() {
$(".delete-attachment").each(function () {
$(this).modalForm({
formURL: $(this).data("form-url"),
modalID: "#std-modal",
asyncUpdate: true,
asyncSettings: {
closeOnSubmit: true,
successMessage: "Deleted.",
dataUrl: "LIST URL",
dataElementId: "#attachments-container",
dataKey: "list",
addModalFormFunction: updateAttachmentModalForm,
}
});
});
}
deleteAttachmentModalForm();
Metadata
Metadata
Assignees
Labels
Q&AQuestions and answersQuestions and answers