フィールドを離れた後、オートコンプリートをキャンセルします
-
03-10-2019 - |
質問
ユーザーがページを離れて、 ここのドキュメント 私は多くのことを見ます
.autocomplete( "destroy" )
.autocomplete( "disable" )
.autocomplete( "close" )
しかし、ユーザーがフィールドを離れた後、どのように使用できますか
$("#request_song").autocomplete({
source: function(req, add){
$.getJSON('<%= ajax_path("trackName") %>', req, function(data) {
var suggestions = data.suggestions;
add(suggestions);
});
},
change: function() {
var main = $('#main_content');
main.empty().append("<img id=\"throbber\" src='/pre_config/css/images/throbber.gif' alt='Loading. Please wait.' />");
$("#band_events").load("/load_events/"+ escape($('#request_artist').val()), successCallback );
},
});
解決
バインドa blur
フィールドへのイベントハンドラー(本質的に失われたフォーカスイベント):
$("#request_song").blur(function(){
// Using disable and close after destroy is redundant; just use destroy
$(this).autocomplete("destroy");
});
所属していません StackOverflow