Kendo ui 动态创建表单中的剑道Ui引用错误

Kendo ui 动态创建表单中的剑道Ui引用错误,kendo-ui,Kendo Ui,我正在使用远程服务器信息创建动态表单。。我的代码是 $.ajax({ url: xxx.php', data: { EXTAPP_ID: extappId, OBJECT_NAME: sessionStorage.getItem('ssObjectName') }, type: 'GET', crossDomain: true, dataType: 'jsonp', success: function (mo

我正在使用远程服务器信息创建动态表单。。我的代码是

$.ajax({
    url: xxx.php',
    data: {
        EXTAPP_ID: extappId,
        OBJECT_NAME: sessionStorage.getItem('ssObjectName')
    },
    type: 'GET',
    crossDomain: true,
    dataType: 'jsonp',
    success: function (model) {
            console.log(model);
              obsRecordFields = kendo.observable(model);
            // bind the model to the container
            kendo.bind($("#recordDetailView"), obsRecordFields);
            kendo.init($("#Field1"));

    }
});
生成表单字段的模板是

<script id="fieldsTemplate" type="text/x-kendo-template">
    <li>
        <label data-bind="attr: { for: name}, text: label"></label>
         # if (get("fieldtype") == "input") {#
        <input data-bind="value: value, attr: { type: type, name: name}" # if (get("required")) {# required #} # />
            #}else{#
                    <select id="name" data-role="dropdownlist" data-bind="source: options, value: value, attr: { type: type, name: name}" data-text-field="option_value" data-value-field="option_id"  />
            #}#

    </li>
</script>

  • #如果(获取(“字段类型”)=“输入”){# #}否则{# #}#
  • 我的问题是

    当我第一次打开页面时,它在控制台日志中返回一个错误,说“Uncaught ReferenceError:option_id未定义”。当我再次刷新同一页面和所有相关函数时,它正在工作。我发现了问题

    我在datainit触发的函数中调用了ajax。事件的顺序是

    绑定视图模型 演出前 初始化 展示

    因此,当我在数据显示上触发该功能时,它开始工作

    谢谢你的非常有用的帖子()帮助解决了这个问题