Vue-form-generator: Form submission

Created on 20 Feb 2017  路  5Comments  路  Source: vue-generators/vue-form-generator

Very nice component! I am trying to submit the form using a 'submit' field. However, I can not seem to get it working when I pass the onSubmit option of the submit button a callback.

Offcourse, I can do submission inline just there, but that's not clean.

For the moment I just have everything inside my root Vue element and trying to pass the onSubmit a callback that I put in the 'methods' object just does nothing.

bug need investigate

Most helpful comment

It's working with method too, just in this case data have to be function and this won't be undefined.

https://jsfiddle.net/0mg1v81e/203/

All 5 comments

Could you make a jsfieddle from the problem?

Hey @pimhooghiemstra
This is a working example https://jsfiddle.net/0mg1v81e/198/
I totally get your point there. When you try to pass a callback it doesn't work https://jsfiddle.net/0mg1v81e/201/
This is mainly due to the fact that vue doesn't recognize other instance details inside data. When you declare data you can't access this.myMethod or some computed because it will blow everything apart when something changes.
A very simple option would be to place the button separately https://jsfiddle.net/0mg1v81e/202/
Maybe I'm missing something there @icebob ?

It's working with method too, just in this case data have to be function and this won't be undefined.

https://jsfiddle.net/0mg1v81e/203/

@icebob that does work indeed! I just didn't know we had to make data a function, did I miss this in the docs?
@cristijora your point of adding the submit separately sort of opened my eyes for this option, nice, but now I see it is possible in one go with the form component I stick with that ;-)

Great work!

Yes, maybe I need to correct the examples.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jewbetcha picture jewbetcha  路  3Comments

zwx00 picture zwx00  路  3Comments

LouWii picture LouWii  路  4Comments

icetee picture icetee  路  4Comments

sjordan1975 picture sjordan1975  路  5Comments