我正在使用backbone撤消js为undo
和redo
,我需要检查撤消或重做是否可用。 有像hasundo()
和hasredo()
检查有撤销/重做主干undo
View = Backbone.View.extend({
initialize: function() {
// If the model's value changes, update the view
this.model.on("change:value", function (model, value, options) {
if (value != this.$el.html()) {
this.$el.html(value);
//need to check here,and add code for enable or disable my undo/redo buttons
}
}, this);
}
})
然后你应该做的是在你的模型中写一个'hasUndo'函数,如果'this.model.hasUndo()'为true,则只显示视图中的“撤销”按钮。 –
是的,你需要在你的模型上创建该功能... –