我正在使用两个filteringSelect创建一个dijit.form.Form,可以动态添加更多自定义过滤选择,但是当我尝试使用xhr.post发布表单时没有提交任何值,我试图转换在发布之前向Json表单,但对象变空。我知道我可以访问所有过滤选择值并发布它们但我的目标是“轻松提交”自动方式。希望提前获得帮助。
define([
"dojox/layout/ContentPane",
"dijit/form/Form",
"dijit/form/Button",
"dojox/widget/Standby",
"app/appCW/appWayP",
"dojo/data/ItemFileReadStore",
"dijit/form/FilteringSelect",
"dojo/_base/xhr",
"dojo/dom",
"dojo/on",
"dojo/dom-form",
"dojo/dom-construct",
"dojo/io/script",
"dojo/_base/lang"
], function(ContentPane,Form,Button,Standby,appWayP,ItemFileReadStore,FilteringSelect,xhr,dom,on,domform,domConstruct,script,lang){
return{
initLayout:function(){
var rtCont= new ContentPane({
title: "Route",
id: "rtCont",
style: "height: 100%; width: 100%;margin:0px;padding:3px",
content:"<DIV class=app_title><SPAN>Routing</SPAN></DIV>"+
"<DIV id='NodesList'></DIV>"
});
dijit.byId("AppsTC").addChild(rtCont);
var nodeStore = new ItemFileReadStore({
identifier: "id",
label: "name",
url:"../NodeService"
});
nodeStore.fetch();
var RouteFrm= new Form({
//encType: 'multipart/form-data',
id:"RouteFrm",
action:"../RouteService",
method:"",
onSubmit:function(e){
dojo.stopEvent(e);
var data = domform.toJson("RouteFrm");
alert(data);
var xhrArgs = {
form: dojo.byId("RouteFrm"),
handleAs: "json",
load: function(data){
},
error: function(error){
}
};
var deferred = xhr.post(xhrArgs);
}
},"NodesList");
//This button to add more filteringselects
var pluswPoint = new Button({
id: "pluswPoint",
label: "Add WayPoint",
showLabel: false,
iconClass: "waypointplus",
onClick: function () {
var wContainer = dom.byId("waypoints_container");
var tmpgtest = new appWayP({
'nodeStore':nodeStore
}).placeAt(wContainer);
tmpgtest.startup();
}
});
//This button to submit form
var showRoute= new Button({
id: "showRoute",
label: "Show Route",
showLabel: true,
type:"submit"
});
var inNode= new FilteringSelect({
id:"inNode",
value: "",
store: nodeStore,
'class': 'node_filteringselect',
searchAttr: "name",
placeholder: "Start"
});
var desNode= new FilteringSelect({
id:"desNode",
value: "",
store: nodeStore,
'class': 'node_filteringselect',
searchAttr: "name",
placeholder: "End"
});
RouteFrm.domNode.appendChild(inNode.domNode);
RouteFrm.domNode.appendChild(pluswPoint.domNode);
domConstruct.create("div",{id:"waypoints_container"},RouteFrm.domNode);
RouteFrm.domNode.appendChild(desNode.domNode);
RouteFrm.domNode.appendChild(showRoute.domNode);
RouteFrm.startup();
rtCont.startup();
}
}
});
答案 0 :(得分:0)
除了过滤选择的id之外,尝试添加名称,如果没有看到名称,表单将不会返回该值。