php - jquery autocomplete: works for first value, how to enable it for next?
I'm using autocomplete so user can easly enter data on inputs, like this:
<?
$a = new etiqueta(0, '');
$b = $a->autocomplete_etiquetas();
?>
<script type="text/javascript">
function cargar_autocomplete_etiquetas(){
$("#tags").autocomplete({
source: [<? echo $b; ?>]
});
}
</script>
$a = $b its an array with a result like: 'help','please',i','need','to,'be able to', 'select next item',' with autocomplete';
and i checked the ui documentation, but it doesn't fith with my source method.. any idea? I'm trying like this (edited with Bugai13 aportation):
<?
$a = new etiqueta(0, '');
$b = $a->autocomplete_etiquetas();
?>
<script type="text/javascript">
function cargar_autocomplete_etiquetas(){
$("#tags").autocomplete({
source: [<? echo $b; ?>],
multiple: true,
multipleSeparator: ", ",
matchContains: true
});
}
</script>
but i don't know how to do it.. any idea? are .push and .pop functions from the autocomplete? or shall i define, them?
thanks again!
PS: i'm getting adicted to this site! PS: come on dudes, i think the answer will be very usefull for many people PS: is it allowed to offer paypal reward?
Answer
Solution:
I've use following to get work multiple autocomplete for tags with ',' separator, hope this help your:
It's full my code that work. In my case in parse function items it just json array, try to add parse method:
So, you need something like this:
Answer
Solution:
What does
echo $b;
print? I would expect you would need something likeecho implode(',', $b)
, or evenecho '"' . implode('", "', $b) . '"';
to make this work, if $b really is a PHP array.Edit: (of course I'm only assuming you're using PHP, but if it
<?
s like PHP and$
s like PHP...)