這是knockout.dirtyFlag.js如何使用requirejs加載koLite?
;(function (ko) {
ko.DirtyFlag = function (objectToTrack, isInitiallyDirty, hashFunction) {
hashFunction = hashFunction || ko.toJSON;
var
_objectToTrack = objectToTrack,
_lastCleanState = ko.observable(hashFunction(_objectToTrack)),
_isInitiallyDirty = ko.observable(isInitiallyDirty),
result = function() {
var self = this;
self.isDirty = ko.computed(function() {
return _isInitiallyDirty() || hashFunction(_objectToTrack) !== _lastCleanState();
});
self.reset = function() {
_lastCleanState(hashFunction(_objectToTrack));
_isInitiallyDirty(false);
};
return self;
};
return result;
};
})(ko);
在我的模型我有一個這樣的定義設置:
define([
"lib/knockout",
"lib/knockout.dirtyFlag"
],
function(ko) {
...
self.dirtyFlag = new ko.DirtyFlag([
}
基本上我得到一個錯誤,說DirtyFlag是不確定的。
我需要做什麼?
說kodf是undefined當我嘗試這個 – 2013-03-07 16:50:57
頁面加載knockout.dirtyFlag.js? – SteveP 2013-03-07 16:53:00
不,我試圖通過require.js – 2013-03-07 16:54:46