1

I want to add an autocomplete (suggestion function) to an editor field in my create menu.

I have this basic razor view @Html.EditorFor(model => model.Title) and I want to add my autocomplete to this.

Previously I have used

<input type="text" name="q"  data-autocomplete="@Url.Action("QuickSearch", "Person")" />
<input  type="submit"  name="submit"  value="Find FullName" />

And I wondered how to implement this.

My Jquery searches for data-autocomplete

$(document).ready(function () {
    $(":input[data-autocomplete]").each(function () {
        $(this).autocomplete({ source: $(this).attr("data-autocomplete") });
   });
})
4

1 回答 1

1

你仍然可以做你以前做过的事情

@Html.TextBoxFor(model => model.Title, new { data_autocomplete="/link" })

请注意,这是TextBoxFor和不是EditorFor。还要注意_data_autocomplete

我不确定这Url.Action部分。您可能必须通过手动插入 url 而不是使用 url.action 自己构建 url。

于 2012-07-13T14:47:08.507 回答