我是Alpaca Forms和Stack Overflow的新手。
我正在尝试使用向导发送表单。我尝试了很多解决方案,但我对方法有疑问。
我已经更改了"属性","表单"和"按钮"的插入,但没有任何效果。
有人知道出了什么问题吗?
<script type="text/javascript">
$("#form1").alpaca({
"dataSource": "./data/customer-profile-data.json",
"schemaSource": "./data/customer-profile-schema.json",
"optionsSource": "./data/customer-profile-options.json",
"view": {
"parent": "bootstrap-edit-horizontal",
"wizard": {
"title": "Welcome to the Wizard",
"description": "Please fill things in as you wish",
"bindings": {
"name": 1,
"age": 1,
"gender": 1,
"photo": 1,
"member": 2,
"phone": 2,
"icecream": 3,
"address": 3,
},
"steps": [{
"title": "Getting Started",
"description": "Basic Information"
}, {
"title": "Details",
"description": "Personal Information"
}, {
"title": "Preferences",
"description": "Customize your Profile",
}],
"form" : {
"method" : "POST",
"action" : "http://httpbin.org/post",
},
"buttons" : {
"submit" : {
"title" : "Sauve Response",
"id": "mySubmit",
"click": function(callback){
console.log("submit() - ".$("#form1"));
},
}
},
/*"attributes": {
"data-test": "123",
"method": "post",
"action": "http://httpbin.org/post"
},
"buttons": {
"submit":{
"value": "Sumbit",
}
}
//"validation": true,
/* "buttons": {
/*"first": {
"title": "Go to First Page",
"align": "left",
"click": function(e) {
this.trigger("moveToStep", {
"index": 0,
"skipValidation": true
});
}
},
"previous": {
"validate": function(callback) {
console.log("Previous validate()");
callback(true);
}
},
"next": {
"validate": function(callback) {
console.log("Next validate()");
callback(true);
}
},*/
/* "submit": {
"title": "All Done!",
"name": "submit",
"type": "submit",
"id": "mySubmit",
"click": function(callback){
console.log("submit()");
},
"submit": function(callback){
console.log("Next validate()");
}
}
}*/
},
//"locale": "es_ES
"locale": "fr_FR",
}
});
</script>
为此,
您可以在提交按钮的点击事件中使用 ajax 或 jquery post 方法,如下所示:
$.post( "//httpbin.org/post", this.getValue());
这是一个工作小提琴。