我使用dojo aspect.before在调用我的原始方法之前执行一些操作。然而,如果aspect.before方法中不满足某些条件,我会尝试取消原始方法,但无法取消该事件。
require(["dojo/_base/declare",
"dojo/_base/lang",
"dojo/aspect",
"dojo/dom",
"dojo/on"],
function(declare, lang, aspect, dom, on) {
aspect.before(target,"onSave", function(event){
var mycriteria = //some logic to determine this value;
if(mycriteria == null || mycriteria == undefined){
//cancel the "onSave" method.
// if cancelling this is not possible, can I call "onCancel" method here that'll cancel this
//event?
}
});
}
1条答案
按热度按时间rpppsulh1#
aspect.around就是你要找的,它允许你替换原来的方法,并按照你自己的方式应用它。