1

我有一个问题,当我使用空字段保存表单时,它会被保存,但是当我打开表单进行编辑时,它会[object object]在该字段中显示而不是空值。我正在寻找在knockout.js表单中循环对象属性的方法。

编辑

表单绑定在这里

ko.bindingHandlers.renderForm = {

    init : function(element, valueAccessor, allBindingsAccessor, viewModel,
            bindingContext) {
        if (!viewModel.formData) {
            viewModel.formData = false;
        }
        if (! isNullOrEmpty(viewModel.formData)) {
            console.log("hello");
            $.each(viewModel.formData, function(key, val){
                if ($.isEmptyObject(val)) {
                    viewModel.formData[key] = '';
                }
            });
        }
        console.log(viewModel.formData['remarks']);
        //viewModel.formData.data = some functionto convertempty object to empty string(viewModel.formData.data);
        renderForm(viewModel.formXml, element, viewModel.formData, viewModel.formOptions);

    }

};
4

0 回答 0