-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete does not display returning data #11
Comments
sorry! I missed your message and haven't checked this project in a while. If this is still an issue, please let me know. |
I ran into a similar issue, when the autocomplete field is cleared the id value is not set. this would ensure that the value id matches the autocomplete. Let me know if there is a better way. Regards |
Floyd, if your fix works, would you mind submitting a pull request with the
change?
…On Tue, Sep 19, 2017 at 2:01 PM, gate21 ***@***.***> wrote:
I ran into a similar issue, when the autocomplete field is cleared the id
value is not set.
I did the following to get around it:
in the typeahead.mvc.model.js
add the following:
}).on('typeahead:change', function (obj) {
onchange(obj);
});
function onchange(obj) {
var obj$ = $(event.target);
var datum = {
id: $('#' + obj$.data("autocomplete-id-field")).val(),
value: event.target.value
};
if (datum.value === "") {
$('#' + jQuery(obj.target).data("autocomplete-id-field")).val("");
}
}
this would ensure that the value id matches the autocomplete.
Let me know if there is a better way.
Regards
Floyd
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALiMXokARRL3CryHJCIsbi56UFNVhbuvks5skCu5gaJpZM4LrPrN>
.
|
I was not able to show the data when Its returned from the action result
This is my model
public class Autocomplete { public int HelloWorldId { get; set; } public string Message { get; set; } public string Name { get; set; } public int PersonId { get; set; } }
in my view i use
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" }) @Html.AutocompleteFor(model => model.Name, model => model.PersonId, "GetPeople", "Shifts", false,new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
an thisis my control
public ActionResult GetPeople(string query) { log.Info($"Start"); var res = _repoPass._GetPeopleList(query); log.Info($"res :{res}"); return Json(res, JsonRequestBehavior.AllowGet); }
with console.log in
typehead.mvc.models.js
i can see I can see that my json returns with the data but its not showing
The text was updated successfully, but these errors were encountered: