【问题标题】:jquery ui helper mvc Select eventjquery ui helper mvc Select 事件
【发布时间】:2016-12-20 09:40:01
【问题描述】:

当用户从 jquery ui 自动完成填充列表中选择时,我正在尝试访问“select”事件我想在 jquery ui 自动完成“Select”事件时触发一个事件
我的问题是
我正在使用 JqueryUiHelper MVC,但不知道如何使用 htmlHelper http://jqueryuihelpers.apphb.com/Docmo/Autocomplete 来使用 select 事件

@using JQueryUIHelpers
    @Html.JQueryUI().AutocompleteFor(x => x.SearchText, Url.Action("SearchFilter"), new { @class = "form-control", placeholder = "Company name here for search..", style = "max-width:none;" }
                     )
@section Styles {
    @Styles.Render("~/Content/jqueryui")
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryui")
}

任何帮助将不胜感激。

【问题讨论】:

  • 首先@Html.JQueryUI().AutocompleteFor(x => x.SearchText,.....)应该在@Scripts.Render section之后。
  • 其工作正常的脚本在章节中定义。

标签: asp.net-mvc jquery-ui jquery-ui-autocomplete


【解决方案1】:

我带来了来自https://api.jqueryui.com/autocomplete/#event-select的解决方案
将事件监听器绑定到 autocompleteselect 事件:

$(function () {
        $("#SearchText").on("autocompleteselect", function (event, ui) {

            event.preventDefault();
            $(this).val(ui.item.value);
            $('#btnGo').click();

        });
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-18
    • 2015-01-26
    • 1970-01-01
    • 2011-07-09
    • 1970-01-01
    • 2012-04-19
    相关资源
    最近更新 更多