jquery auto complete for dynamically generated textboxes

后端 未结 5 2109
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 11:45

i am new to jquery, i am working on a web page which needs generating text boxes dynamically with autocomplete facility.

i tested $(\"#some\")

5条回答
  •  青春惊慌失措
    2020-12-05 12:06

    You need to add the autocomplete handler to each element as you add it. The elements that don't exist when you apply it on document load will never have it applied otherwise. Also, you'd be better off creating the row and input separately. By doing that you could just use the reference to the newly created input and use it with the autocomplete plugin.

    $(function() {  
    
        $("#button_newproduct").click(function(){
             var input = $("");
             var row = $('').append( $('').append(input) );  
             $("#products_table > tbody").append(row);
             var data = "Core celectors cttributes craversing canipulation CSS cvents cffects cjax ctilities".split(" ");
             input.autocomplete(data);
    
        });
    });
    

提交回复
热议问题