KeyPress event for ComboBox

2 posts, 0 answers
  1. Sean
    Sean avatar
    1 posts
    Member since:
    Jan 2015

    Posted 14 Oct Link to this post

    I am trying to call a function each time a key is pressed in the textbox of the combobox to update another pulldown box.

     

    Here is my razor code.

     

                                            @(Html.Kendo().ComboBoxFor(m => m.ToAccountID)
                                                .Name("ToAccountID")
                                                .DataTextField("Text")
                                                .DataValueField("Value")
                                                .HtmlAttributes(new { style = "width:100%;" })
                                                .BindTo(acctList)
                                                .Events(e =>
                                                    {
                                                        e.Select("onToSelectChange");
                                                    })
                                            )

     

    I have tried this but get a javascript error.

      // javascript

        $("#ToAccountID").data("kendoComboBox").input.keypress(function(){
            console.log("pressed");
        });

     

    Error:

    TypeError: $(...).data(...) is null
    <anonymous>

    Thanks.

  2. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 18 Oct Link to this post

    Hello Sean,

    Try to transfer your logic after the page is loaded and ready:
    https://learn.jquery.com/using-jquery-core/document-ready/

    That should resolve the issue.

    Regards,
    Eyup
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top