I am getting strange behavior when I turned off the autosuggest programmatically.
The scenario is that I have a KendoAutoComplete input box along with search button. The search result come from both typing characters and pressing the search button. The requirement is that autosuggest should work when user has type at least 3 characters in the input, but the search button should open autosuggest even if one character is typed.
In order to do that I used the following code below:
var turnOffAutoComplete = function () {
autocomplete.options.suggest = false;
autocomplete.bind("open", function (e) {
e.preventDefault();
});
};
var turnOnAutoComplete = function () {
autocomplete.unbind("open");
autocomplete.options.suggest = true;
};
$("#input_text").keyup(function () {
if ($(this).val().length >= 3) {
turnOnAutoComplete();
}
else {
turnOffAutoComplete();
}
});
$("#search-button").click(function () {
turnOnAutoComplete();
var val = $('#input_text').val();
autocomplete.search(val);
});
The code above is causing the screen to becomes blank when user clicks anywhere on the screen after typing one character (autosuggest data is being fetchedfor first time). I checked in console, and saw <body> having style "display:none".
Anyone knows why this would be happening? Need help asap.