Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create asynchronously without updating or rendering #164

Open
JohannesPertl opened this issue Apr 12, 2021 · 4 comments
Open

Create asynchronously without updating or rendering #164

JohannesPertl opened this issue Apr 12, 2021 · 4 comments
Labels
enhancement New feature or request high priority

Comments

@JohannesPertl
Copy link

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?

@trco trco added the Q&A Questions and answers label Apr 12, 2021
@trco
Copy link
Owner

trco commented Apr 12, 2021

@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?

@JohannesPertl
Copy link
Author

JohannesPertl commented Apr 12, 2021

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

@trco trco added the enhancement New feature or request label Apr 16, 2021
@trco
Copy link
Owner

trco commented Apr 16, 2021

@JohannesPertl I'll do my best to sort this out as soon as possible.

@trco trco removed the Q&A Questions and answers label Apr 16, 2021
@infosrabah
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request high priority
Projects
None yet
Development

No branches or pull requests

3 participants