jQuery v1.8.3 と jQuery UI v1.9.2 を使用しています。この方法でオートコンプリートウィジェットを実装しました。
$('#input_id').autocomplete({
create: function (event, ui) {
// Initialize data
$(this).data( 'custom', { property1: 'Hello', property2: { num: 1, funct: function() { ... return value } } );
alert($(this).data('custom').property1) // Display 'Hello'
},
select: function(event, ui) {
alert($(this).data('custom').property1) // Display 'Hello'
},
source: function(request, response) {
alert($(this).data('custom').property1) // Display 'undefined'
alert(this.data('custom').property1) // I get 'TypeError: this.data is not a function'
}
});
なぜ私が中にsource
入るオプションと私が得るイベントなのですか?オプションコンテキストでプロパティに適切にアクセスして取得するにはどうすればよいですか?undefined
create
select
Hello
number
search
Hello