简体   繁体   English

FilteringSelect值未在dojo表单中提交

[英]FilteringSelect values not submiting in dojo Form

I'm making a dijit.form.Form with two filteringSelect with the possibility to add more custom filteringselects dynamically, but when I try to post the Form with xhr.post no values are submitted, I've tried to convert the form to Json before posting but the object comes empty. 我正在使用两个filteringSelect创建一个dijit.form.Form,可以动态添加更多自定义过滤选择,但是当我尝试使用xhr.post发布表单时没有提交任何值,我试图将表单转换为Json在发布之前,但对象变空。 I know I can access all the filteringselects values and post them but I was aiming for the "easy submit" automatic way.Thanks for the help in advance. 我知道我可以访问所有过滤选择值并发布它们但我的目标是“轻松提交”自动方式。谢谢你提前帮助。

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();
    }
}
});

除了过滤选择的id之外,尝试添加名称,如果没有看到名称,表单将不会返回该值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM