how to reset a form?

639 views
Skip to first unread message

Jakub Wolny

unread,
Nov 8, 2013, 10:02:32 AM11/8/13
to backbon...@googlegroups.com
Hi,

I am new to Backbone forms, that why my question might be stupid.

I have a simple form that I am using to add new records to database. In my case after form.commit and record.save I want to reset form to the default state.

Calling internal "reset" method of HTML form is not good solution because of missing default values.

I know that I can create new form every time, but it is ugly and tricky solutions, so I am sure that has to be easier one.

Phil Freo

unread,
Nov 8, 2013, 2:51:01 PM11/8/13
to backbon...@googlegroups.com
How about just calling `form.render()` again on the form?

________________________
Phil Freo, Jr.
http://philfreo.com/


--
You received this message because you are subscribed to the Google Groups "Backbone-forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to backbone-form...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jakub Wolny

unread,
Nov 10, 2013, 2:45:27 PM11/10/13
to backbon...@googlegroups.com
When I again execute form.render() inputs disappear.

I have found out working solution:
record = new Model(); // creating new instance of model
form.model = record;  
form.setValue(record.attributes); // populate new values to inputs

Maybe this should be mentioned in the documentation?

What do you think about adding "reset" method to form (and editors) to reset form inputs to default value? 
Reply all
Reply to author
Forward
0 new messages