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") });
   });
})
2

1 Answer 1

1

You can still do what you previously had

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

note that this is TextBoxFor and not EditorFor. Also note the _ in data_autocomplete

I'm not sure about the Url.Action part. You may have to build the url yourself by manually inserting a url rather than use url.action.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.