I am using dojo aspect.before to perform some actions prior to calling my original method. However, I am trying to cancel the original method if some criteria is not met within the aspect.before method, but not able to cancel that event.
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?
}
});
}
aspect.around is what you're looking for. It allows you to substitute the original method and apply it on your own terms.