我遇到一个问题,当我使用空字段保存表单时,它会被保存,但是当我打开表单进行编辑时,它会在该字段中显示[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);
}
};