2016-03-03 121 views
1

我有一种形式,下一个按钮。在点击这个下一个按钮时,它应该导航到其他表单。使用Alpacajs从一种形式导航到另一种形式

我已经创建了两种形式,但我无法链接它们。

$("#field1").alpaca({ 
    "schema": { 
     "title": "Name Info", 
     "type": "object", 
     "properties": { 
      "firstName": { 
       "title": "First Name", 
       "type": "string" 
      }, 
      "lastName": { 
       "title": "Last Name", 
       "type": "string" 
      } 
     } 
    }, 
    "options": { 
     "form": { 
      "buttons": { 
       "next": { 
        "click": function() {} 
       } 
      } 
     } 
    } 
}); 
+0

你能告诉我们你的源代码吗? 。 – Genzotto

+0

$( “#字段1”),羊驼({ “纲目”:{ “称号”: “名称信息”, “类型”: “对象”, “属性”:{ “名字”:{ “头衔”: “名”, “类型”: “串” }, “姓氏”:{ “称号”: “姓”, “类型”: “串” } } } , “options”:{ “form”:{ “buttons”:{ “next”:{ “click”:function(){ } } } } } }); – smileisbest

+0

这是我的第一种形式,有两个字段firstname和lastname。接下来有一个按钮。点击下一步,它应该导航到其他表单。我有一个查询,如何从这个表单导航到其他表单。我必须在这个点击函数内写入,以便导航到其他表单 – smileisbest

回答

0

您是否尝试过使用Wizards,我认为这可能会对您有所帮助。告诉我如果这不是你要找的,我会尽力帮助你。

+0

感谢您的回复。我不是在寻找巫师。我只是想要一种形式。如果我们点击下一个按钮,它应该导航到其他表单,而不是像向导这样的不同步骤。但步骤一样 – smileisbest

0

@smileisbest和@ Shabbir-Dhangot,我在同一页面中实现了两种形式。使用JSON库序列化数据并传送到下一个表格:

"click" : function() { 
var editJsonData = JSON.stringify(this.getValue(), null, " "); 
doNext(editJsonData); 
} 

然后调用next形式添加为一个功能:

// If JSON data is not null, the next form will display. 
var doNext = function(jsonData) { 
    $("#NextForm").empty(); 
    if (null != jsonData) { 
     // Validate user or data... 
     // This starts the Editor form 
     $("#NextForm").alpaca({ 
"data" : jsonData, 
"schema" : { 
"type" : "object", 
"properties" : { ... 

使用显示/隐藏适当隐藏前形式:

$("#field1").hide(); 
$("#NextForm").show();