This is a migrated thread and some comments may be shown as answers.

KeyPress event for ComboBox

1 Answer 335 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 14 Oct 2016, 07:08 PM

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.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 18 Oct 2016, 02:33 PM
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
Tags
ComboBox
Asked by
Sean
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or