Michael Mahony
Michael Mahony

Reputation: 1350

Referencing Telerik RadComboBox in JQuery

I have the following Telerik RadComboBox defined in my code:

<telerik:RadComboBox ID="rcbCustomer" runat="server" CssClass="form-control field-standard-size fix-background-    white input-sm" width ="300px" Height="140px"
                    EmptyMessage="Type here to find sold-to customer" LoadingMessage="Please wait, loading..."     AutoPostBack="true"
                    RegisterWithScriptManager="false" EnableEmbeddedScripts="true"     EnableVirtualScrolling="true">
                </telerik:RadComboBox>

I want to grab the onchange and do something with JQuery. As a test I have the following JQuery code:

<script>
    $telerik.$("#<%=rcbcustomer.ClientID %>").onchange(function(e){
        e.preventDefault();
        alert("changed");
    });
</script>

The JQuery code is not executed at all. Does anyone have a clue as to ho9w to make this work?

Upvotes: 0

Views: 688

Answers (1)

AlexanderM
AlexanderM

Reputation: 1683

I do not believe you will be able to attach event listener like that to Telerik controls. I think you will need to use OnClientSelectedIndexChanging or OnClientSelectedIndexChanged (http://www.telerik.com/help/aspnet-ajax/combobox-client-side-events.html)

So by end of the day you will have something like:

In control definition you will add OnClientSelectedIndexChanging="rcbCustomer_IndexChanging"

<script>
function rcbCustomer_IndexChanging(e, args){
    e.preventDefault();
    alert("changed");
}
</script>

PS: Keep in mind that one telerik control could be rendered as numerous DOM elements with quite a lot of different Ids, where control with id="rcbCustomer" is just a div, anchor or not visible at all and user interacts actually with something else.

Upvotes: 1

Related Questions