0

私は午前中ずっとこれに行き詰まっていました: オートコンプリートを動的に使用したいのですが、_renderItem を呼び出して、サーバーが返すすべてのアイテムを表示する必要があります。私は完全に静的に動作するコードを持っていました。ここで、この部分を DOM に動的にもたらす、より柔軟なソリューションである Web が必要です。うまくいくと思っていたものを変更しましたが、うまくいきません。これは私のコードを簡略化したものです:

$(document).ready(function(){

var site_id = 'site_id';

// Use the .autocomplete() method to compile the list based on input from user
$('#itemCode').livequery( function() {
    $(this).autocomplete({
        source: 'include/autocompletado_promos.php?site_id=' + site_id,
        minLength: 1,
        select: function(event, ui) {
            return false;
        }
    });

}).data( "autocomplete" )._renderItem = function(ul, item) {
    alert("works!");

}); 

何が問題なのですか?事前にどうもありがとう!!!

4

1 に答える 1

0

編集:わかりました、何度も何度も間違っていたことに気づきました。これが最終的なコードの動作です:

    $(this).autocomplete({
        source: 'include/autocompletado_promos.php?site_id=' + site_id,
        minLength: 1,
        select: function(event, ui) {
            return false;
        }
    }).data( "autocomplete" )._renderItem = function(ul, item) {
         alert("works!");
    };

ありがとう!

于 2012-12-10T10:03:23.383 に答える