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

Trongate MX !element.hasAttribute(httpMethodAttribute) #207

Open
vanHeerwaarden opened this issue Oct 9, 2024 · 0 comments
Open

Trongate MX !element.hasAttribute(httpMethodAttribute) #207

vanHeerwaarden opened this issue Oct 9, 2024 · 0 comments

Comments

@vanHeerwaarden
Copy link

Hi David,
I will complement you with another great future in the trongate framework.
After completed the tutorial I was attended the placeholder information is not resetting. So I did a console.log(httpMethodAttribute)

invokeFormPost(element, triggerEvent, httpMethodAttribute, containingForm, event) {
            const { http, formData, targetElement } = Http.commonHttpRequest(element, httpMethodAttribute, containingForm);

            http.onload = function() {
                Dom.attemptHideLoader(containingForm);
                
                const isSuccessfulResponse = http.status >= 200 && http.status < 300;
                const shouldResetForm = isSuccessfulResponse && element.hasAttribute(httpMethodAttribute);
                
                if (shouldResetForm) {
                    containingForm.reset();                    
                }
                // containingForm.reset();
                console.log(httpMethodAttribute)
                
                const responseTarget = element.hasAttribute(httpMethodAttribute) ? **!**element : containingForm;
                Http.handleHttpResponse(http, responseTarget, event);
            };

            try {
                http.send(formData);
            } catch (error) {
                Dom.attemptHideLoader(containingForm);
                console.error('Error sending form request:', error);
            }
        },

console.log(httpMethodAttribute) returns mx-post

So I removed the ! before element : containingForm; now my code behave as I expected. So my question: is this a mistake in the mx code (you can modify) or do I have to check my tutorial code?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant