Answer the question
In order to leave comments, you need to log in
How to "friend" jquery ui autocomplete with dynamic form?
I'm making a dynamic form with autocomplete values from the database.
<FORM class = "filmfields" name = "edit" method="post" action = "<?=$_SERVER['REQUEST_URI']?>" enctype="multipart/form-data">
<INPUT type = "text" name = "name[]" id= "name" value = "" size = "50"><BR>
<SCRIPT>_tmpl_name='<INPUT type = "text" name = "name[]" id= "name" value = "" size = "50"><BR>';</SCRIPT>
<INPUT type = "button" value = "+" onclick = "$(this).before(_tmpl_name);">
</FORM>
Answer the question
In order to leave comments, you need to log in
And now attention! Correct answer:
$(document).on("focus",[selector],function(e) {
if ( !$(this).data("autocomplete") ) { // If the autocomplete wasn't called yet:
$(this).autocomplete({ // call it
source:['abc','ade','afg'] // passing some parameters
});
}
});
var count = 0;
$(cloneButton).click(function() {
var newid = "cloned_" + (count++); // Generates a unique id
var clone = $(source) // the input with autocomplete your want to clone
.clone()
.attr("id",newid) // Must give a new id with clone
.val("") // Clear the value (optional)
.appendTo(target);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question