Webix richselect 在表单提交(提交按钮单击)时不断重置(到以前的值)

Webix richselect keeps resetting (to former value) on form submit (submit button click)

我有一个与 AngularJS 集成的 webix 表单,我在使用这个框架时遇到了一个又一个挑战。到目前为止,我一直坚持使用它,因为我觉得它是最合适的选择。如果需要,我很乐意 post 编码。

但我只是想询问我的 richselect(基于 AngularJS)如何或为什么在初始表单提交时保持原始值(无页面重新加载)。此外,在页面重新加载(ater 提交)时,我的 richselect 假定了正确的值。

我该如何解决这个问题?

<div id="formcontainer"  ng-app="Risk" ng-controller="EditRiskController as ctrl">
    <get-risk></get-risk>
    <div ng-if="ctrl.initDone && ctrl.userDone" id="myeditform" layout-padding="" ng-cloak="">   
        <form id="form" name="EditRisk" role="form"
              ng-submit="ctrl.valid() && ctrl.submit()" novalidate>
             <div ng-show="ctrl.config.owner.done" config="owner"
                  webix-ui="owner" id="owner" width="200" height="30" 
                  name="owner" options="users" type="richselect" />
             <button id="submit" type="submit" class="raised primary">
               Edit Risk
             </button>
        </form>
    </div>
</div>

RichSelect 初始化代码

if (view == "richselect")
{
    config.value = scope.ctrl.risk[attr] || 0; 
    config.options = scope.ctrl[options];

    config.on =  {
        "onChange": function(){
            var obj = this.eventSource || this; 
            scope.ctrl.getItemValueAndValidate(obj, scope.ctrl, attr);
        }
    };
}

获取配置初始化代码中引用的项目值(无验证)

commonFunctions.getItemValue = function(obj, scope, type, field){
    if (!obj && !obj.getValue()){
         scope[type][field] = '';   
         return;
    }
    scope[type][field] = obj.value || obj.data.value;          
}

查看下面的代码,其中添加 config.value = obj.getValue(); 完全解决了问题。

            if (view == "richselect")
            {
                config.value = scope.ctrl.risk[attr];
                config.options = scope.ctrl[options];

                config.on =  {
                    "onChange": function(){
                        var obj = this.eventSource || this; 
                        scope.ctrl.getItemValueAndValidate(obj, scope.ctrl, attr);
                        config.value = obj.getValue();   //adding this fixed the problem
                    }
                }
            }