A form is submitted using the forms submit method.
var view = new ludo.View({
form:{
},
children:[
{ type:"form.Text", name:"firstname", value:"Jane" },
{ type:"form.Text", name:"lastname", value: "Peterson" }
]
})
view.getForm().submit();
Before a form can be submitted, we need to configure form submission. This is done using in a submit object like below:
var view = new ludo.View({
form:{
submit: {
url : 'save.html',
data:{ save: 1 },
method:'post',
listeners:{
init: function(form){},
success: function(json, form){},
fail: function(text, error, form) {}
}
}
},
children:[
{ type:"form.Text", name:"firstname", value:"Jane" },
{ type:"form.Text", name:"lastname", value: "Peterson" }
]
})
view.getForm().submit();
These are the available properties:
In the example above, data will be saved to the file save.html. The form will be submitted using jQuery Ajax. These data will be sent:
{
"save": 1,
"firstname": "Jane",
"lastname": "Peterson"
}
"save": 1 is defined in the data object. firstname and lastname are form fields.