Why this work
$("#tag-search").autocomplete({
autoFocus: true,
source: tags,
messages: {
noResult: '',
results: function () {}
},
select: function (e, ui) {
$('.tags').append('<span class="tag-style">' + ui.item.value + '<i class="fa fa-times tag-del" aria-hidden="true"></i></span>');
ui.item.value = "";
$('.tag-del').click(function () {
$(this).parent().remove();
});
}
});
and this no?
$("#tag-search").autocomplete({
autoFocus: true,
source: tags,
messages: {
noResult: '',
results: function () {}
},
select: function (e, ui) {
$('.tags').append('<span class="tag-style">' + ui.item.value + '<i class="fa fa-times tag-del" aria-hidden="true"></i></span>');
ui.item.value = "";
}
});
$('.tag-del').click(function () {
$(this).parent().remove();
});
I have never understood how javascript is compiled and how work functions! Someone can help me? And last thing: is better write javascript in body page or in a external file? If i should write in external file how can send php response to javascript file? Thanks!