Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can jQuery UI widgets autocomplete work with delegate on clones?

I'm trying to get autocomplete to work on clones by using delegate, but it doesn't appear to be working in Google Chrome.

Here's my attempt: http://jsfiddle.net/uGdm2/

Any ideas?

Thanks.

like image 485
HM2K Avatar asked Feb 03 '26 22:02

HM2K


1 Answers

Yup try this:

var tags = ["PHP", "Perl", "Python"];
$('body').delegate('input.tags', 'focusin', function() {
    if($(this).is(':data(autocomplete)')) return;
    $(this).autocomplete({
        "source": tags
    });
});
var tagsdiv = $('#tags');
$('body').delegate('a.copy', 'click', function(e) {
    e.preventDefault();
    $(this).closest('div').clone().appendTo(tagsdiv);
});

http://jsfiddle.net/petersendidit/uGdm2/4/

like image 116
PetersenDidIt Avatar answered Feb 05 '26 12:02

PetersenDidIt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!