I can't seem to get this to work, I have also tried using a string and string list but I didn't have any luck with that either.
@{
List<string> yyy = new List<string>();
foreach (var x in Model)
{
yyy.Add(x.Name);
}
string[] myArray = yyy.ToArray();
}
<script>
$(function() {
var availableTags = @myArray;
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
The error I get:
JavaScript critical error at line 70, column 39 in http://localhost:42697/Units
SCRIPT1002: Syntax error
In the code it shows:
<script>
$(function() {
var availableTags = System.String[];
$( "#tags" ).autocomplete({
source: availableTags
});
What am I doing wrong here?