PDA

View Full Version : Issue with typeAhead combo-- disabling and re-enabling call to combo stores proxy



JohnJones357
31 Jul 2014, 1:03 PM
I have a combo with typeAhead true, queryMode:"remote". In the event user enters a search that does not yield any results, server will send "success":false. However, this does not mean the user cant submit the query, so i highlight the combo and display a tooltip saying something along the lines of "search didnt yield any results, continue entering in the actual value anyway".

At this point, I disable typeAhead request in the stores "beforeload" handler because once success = false, every char after that will make another request which will keep failing on the backend, so I disable the call in the beforeload event. The issue is, RE-ENABLING the call.


//store listeners
listeners:{
"scope":this,
"beforeload":function(store_, op_) {
if(this.stopLoad === false){
return false;
}else{
return true;
}
//delete this.stopLoad;
},
"load": function (store_, recs_, success_){

if( success_ === false ){
this.stopLoad = success_;
this.markInvalid("Blah,Search did not yield any results. enter in actual value anyway");
}
}
}


so the success flag value (t or f) gets saved in this.stopLoad variable. Once its false, it will invoke the IF condition in beforeload and not make the request. The first time around this works just fine, but once this has happened, this.stopLoad remains false and thus if you delete the search and enter a new one, NO CALL WILL BE MADE, because this.stopLoad still = false.

I tried deleting (delete) this.stopLoad in various places but to no avail.

skirtle
31 Jul 2014, 4:18 PM
A boolean flag is never going to work. You need to compare the text. You may be able to get it work with lastQuery but there's a risk of a race condition if you aren't careful.