I downloaded this plugin:
http://code.google.com/p/jquery-autocomplete/
I write this:
$(document).ready(function () {
$('#txtStoryTags').autocomplete('@Url.Action("GetTags", "Thread")', { dataType: 'json',
parse: function (data) {
var rows = new Array();
for (var i = 0; i < data.length; i++) {
rows[i] = { data: data[i], value: data[i].Name, result: data[i].Name };
}
return rows;
},
formatItem: function (row) {
return row.Name;
},
delay: 40,
autofill: true,
selectFirst: false,
highlight: false,
multiple: true,
multipleSeparator: ";"
});
});
And the Json result is:
[{"TagID":2,"Name":"tag1","Weight":4},{"TagID":4,"Name":"tag2","Weight":1},
Until this point it’s fine.
But when I try to use autocomplete I get in result:
[object Object],[object Object],[object Object],[object Object],[object Object]
Well that’s not expect result.
The question is, what’s wrong about that client script ? I’m pretty sure the problem lays here, just don’t know exactly where.
I’m guessing but
…looks wrong to me. The ‘rows’ you provide the plugin have
data,valueandresultfields, but noNamefield.