我是新手,需要js并且喜欢它到目前为止。我有它与淘汰赛js工作juste罚款。然后我介绍了一个名为ko.editables(But it is able to be the destination index path for other cell to move to(screenshot).)的插件,它可以很容易地撤消更改。
我在我的equirejs配置文件中添加了路径,以便ko.editables具有淘汰,因为它的依赖性。在我的淘汰应用程序代码中我定义了敲除然后ko.editables和文件(knockout.js和ko.editables.js)从我在crome控制台源中看到的正确加载。
这是我的requirejs配置文件:
define(["knockout", "ko_editables"], function(ko, editables) {
... I hide some code here just to show the ko.editable functions im using.
self.Edit = function (incident) {
var CurrentEdititngIncident = self.EditingIncident();
if (CurrentEdititngIncident && CurrentEdititngIncident != incident) {
if (CurrentEdititngIncident.hasChanges()) {
if (confirm('Your have unsaved changes. Press Ok to cancel these changes. Press Cancel to continue editing')) {
CurrentEdititngIncident.rollback();
} else {
return;
}
};
}
ko.editable(incident);
incident.beginEdit();
self.EditingIncident(incident);
self.showDialog(true);
};
self.SaveorUpdate = function (incident) {
var id = this.ID,
self.EditingIncident().commit();
url = Incident.BASE_URL + (id ? '(' + encodeURIComponent(id) + ')' : '');
return $.ajax(url, {
type: id ? "MERGE" : "POST",
data: ko.toJSON({
Description: this.Description,
Incident: this.Incident
}),
processData: false,
contentType: "application/json;odata=verbose",
headers: id ? Incident.UPDATE_HEADERS : Incident.CREATE_HEADERS,
success: function (incident) {
self.showDialog(false);
self.EditingIncident(undefined);
console.log("Record was sucessfully saved.");
}
});
... I hide some code here just to show the ko.editable functions im using.
};
这是我控制我的淘汰视图模型的应用程序代码。
{{1}}
我在jsfiddle中创建了一个没有requirejs的版本,以证明相同的代码在没有requirejs的情况下工作。所以我不太清楚我们失踪了什么。我去了网站https://github.com/romanych/ko.editables,它提到它的AMD兼容,但无法找到有关如何正确加载它的信息。
希望有些人熟悉requirejs或ko.editables。有人会有任何想法吗?