javascript - using string in jquery -
please help me in site. seek utilize autocomplete filed jquery, , value take string javascript variable. why there using 1 string, , not array?
var my_string = "\"ololo1\", \"ololo2\"" var availabletags = [ my_string ]; $( "#autocomplete" ).autocomplete({ source: availabletags });
have 1 : http://i.stack.imgur.com/wh1oy.png
but if set static variable, ok, explain me please :
var availabletags = [ "ololo", "ololo2" ]; $( "#autocomplete" ).autocomplete({ source: availabletags });
result : http://i.stack.imgur.com/vvt90.png
thanks
here,
var my_string = "\"ololo1\", \"ololo2\"" var availabletags = [ my_string ];
availabletags
array of 1 element "ololo1", "ololo2"
. not array of elements "ololo1"
, "ololo2"
, might have thought.
to utilize my_string
source, split transform array of tags. i'd remove double quotes.
var my_string = "ololo1,ololo2"; var availabletags = my_string.split(',');
javascript jquery
No comments:
Post a Comment