I have a search that makes a remote API call to send in the value and this works fine.
People can search by location name or postcode. I was hoping to capture before:flexdatalist.search for example do some regex on the value and cancel the event if there is a match. With some basic attempts though I have been unable to cancel the search going to the remote API.
Maybe I am not doing this right, maybe there is a better event to handle or maybe cancelling this event isn't possible? I've tried handling before:flexdatalist.searchbefore:flexdatalist.data and change:flexdatalist also jQuery change
$(".flexdatalist").flexdatalist({
minLength: 3,
url: "/property/search",
keywordParamName: "locationName"
}).on("before:flexdatalist.search", function (event, data, options) {
console.log(event);
console.log(data);
console.log(options);
if (true) { // catch everything for testing
event.stopPropagation();
event.preventDefault();
return false;
}
});
You would like to prevent sending search requests to the remote API? Hmm... maybe removing the url from options, setting options.url to null. This would certainly prevent the remote request.
I have a search that makes a remote API call to send in the value and this works fine.
People can search by location name or postcode. I was hoping to capture
before:flexdatalist.search
for example do some regex on the value and cancel the event if there is a match. With some basic attempts though I have been unable to cancel the search going to the remote API.Maybe I am not doing this right, maybe there is a better event to handle or maybe cancelling this event isn't possible? I've tried handling
before:flexdatalist.search
before:flexdatalist.data
andchange:flexdatalist
also jQuerychange