【发布时间】:2019-05-11 00:26:17
【问题描述】:
我想从 CSHTML 中解析参数 foreach。使用来自 knockout.js <div data-bind="foreach: viewPjsp(1)"> 的 foreach。
Javascipt:
function ColumnInput(Id, NameColumn) {
var self;
self = this;
self.Id = ko.observable(Id || null);
self.NameColumn = ko.observable(NameColumn || null);
}
(function () {
'use strict';
function ElicensingPjspViewModel() {
var self = this;
self.viewPjsp = ko.observableArray([]);
self.getViewPjsp = function (data, event) {
var url;
$.ajax({
type: "GET",
url: $.rootDir + 'PJSP/PjspEvaluationDetail?AspectId=1', --> here parameter I want to parsing
success: function (data) {
var result;
console.log(data);
result = ko.utils.arrayMap(data.permission, function (item) {
return new KolomInput(item.Id, item.NameColumn);
});
self.viewPjsp(result);
},
error: function (xhr) {
alert(xhr.responseText);
}
});
};
self.getViewPjsp();
}
ko.applyBindings(new ElicensingPjspViewModel(), document.getElementById('pjsp_prinsipal'));
}());
此Javascript 尚未使用参数。如何调用 viewPjsp(1) 然后使用参数?AspectId=xxxx 发送到 ajax 中的 URL。如何将参数敲除从 html 传递到 javascript
【问题讨论】:
标签: jquery asp.net-mvc knockout.js