请从.cshtml页面
中找到以下代码下面的代码为observable提供数据绑定,但不为可观察数组提供数据。
var getLocationDetails = function (locationCode)
{
return $.getJSON('@Url.Action("MasterDetails")',
{ locationcode: locationCode });
};
var setModelData = function (self, locationDetails)
{
self.UneditedLocationDetails = _(locationDetails).cloneDeep();
for (var key in locationDetails)
{
locationDetails[key] = ko.observable(locationDetails[key]);
}
function LocationModifyViewModel()
{
var self = this;
initAjax(self);
var initModel = setModelData.bind(self);
var initModel = setModelData.bind(self);
self.TextboxLocationcode.subscribe(function (val)
{
getLocationDetails(val).success(function (locationDetails) {
setModelData(self, locationDetails);
});
在上面代码为locationDetails
的代码中,我想将observablearray值添加到locationDetails,或者如果可能的话,添加到新变量。