我有一个淘汰模型并将其与我的 asp.net mvc 视图绑定。这是我的模型
function SearchListingViewModel() {
var self = this;
self.selectedBedRooms = ko.observableArray([]);
self.minPrice = ko.observable();
self.search = function () {
var data = {
Status: self.selectedStatus(),
MinPrice: self.minPrice(),
MaxPrice: self.maxPrice(),
BedRooms: self.selectedBedRooms(),
PageNumber: 0,
PageSize : self.pageSize()
};
$.post("/listing/searchlistings", data)
.done(function (json) {
self.Listings(json.listings);
json = json || {};
if (json.success) {
//Inserting commas in all listing's price --- Start
$(json.listings).each(function () {
var selfthis = this;
console.log(selfthis.Price);
selfthis.Price = "45,352,2"; // You can see i am hardcoding price here
console.log(selfthis.Price);
});
//Inserting commas in all listing's price --- End
self.Listings(json.listings);
self.pages(json.pages);
self.pageCount(json.pageCount);
if (self.Listings().length <= 0) {
Alert.Information('No results found!');
}
} else if (json.errors) {
Alert.Error(json.errors[0]);
}
});
}
我的观点
<div data-bind="foreach : Listings">
<span data-bind="text:Price"></span>
</div>
json数据
{Price:555555, Commission:0, MarketingDescription:null, ListingStatusId:1, PlaceId:32, Place:null,…}
当它渲染时,它会在屏幕上显示
555555 43434343 5454545454 4563665 343
代替
45,352,2 45,352,2 45,352,2 45,352,2 45,352,2
什么问题?
提前致谢