So in your attribute-change event handler you call a function that returns a deferred.
function getMax(evt){
var def = new Deferred();
var query = new Query();
var queryTask = new QueryTask( ... );
query.where = "STATE_NAME = 'Washington'";
query.outSpatialReference = {wkid:102100};
query.returnGeometry = true;
query.outFields = ["CITY_NAME"];
queryTask.execute(query, lang.hitch(this, function(responce){
def.resolve(response);
}));
return def;
}
When you call this function you do this:
getMax().then(function(result){
});
So this is a deferred calling a deferred.
Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.