I use jQuery UI Autocomplete.
Part of script is:
$("input[data-autocomplete]").each(function () {
var availableTags = ["first", "second"];
And it works -autocomplete with “first” and “second”
Now i want to assign avalibleTags dinamicly like something like:
var availableTags = @Viewbag.Something
or
var availableTags = @Url.Action('Tags","Home")
It is possible? How to do it in a good way?
In your view you can do:
(This uses JQuery)
Would work. Where the action is in controller like:
Note, the use of the attribute and JSON to allow Javascript communication.
Edit: woops, used key words.