django-bootstrap-modal-forms
django-bootstrap-modal-forms copied to clipboard
Create asynchronously without updating or rendering
I'm implementing a feedback form modal. All I need is a simple form that creates a Feedback model without refreshing the page after submit.
It seems that asyncSettings always needs dataUrl, dataElementId and dataKey though, or else it doesn't create an object. Is it possible to simply create a model without those parameters?
@JohannesPertl At the moment you can't do that, since as you stated specific parameters are needed. If I understand your case correctly you would like to create Feedback asynchronously, show success message but not update the existing page with given Feedback. Right?
Yes exactly, thanks for the quick answer :) At the moment my workaround is to use the parameters with nonsense data like this:
function createFeedbackAsyncModalForm() {
$(".create-feedback").modalForm({
formURL: "{% url 'create_feedback' %}",
modalID: "#create-modal",
asyncUpdate: true,
asyncSettings: {
closeOnSubmit: true,
successMessage: asyncSuccessMessageCreate,
dataUrl: "feedback/",
dataElementId: "nonsense",
dataKey: "nonsense",
addModalFormFunction: createFeedbackAsyncModalForm
}
});
}
createFeedbackAsyncModalForm();
and in the views.py
def feedback(request):
if request.method == 'GET':
return HttpResponse(200)
It would be cleaner if those workarounds were not needed
@JohannesPertl I'll do my best to sort this out as soon as possible.
I was hoping to have this kind of implementation in Asyn for some of my models. Where I want to create a model without giving any other parameter except : SuccessMessage.
So that way it just close the Modal and show a success message if the model has been created
Thank you Uros.