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

User Control javascript event bubbling from RadCombobox

2 Answers 47 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Troy
Top achievements
Rank 1
Troy asked on 21 Dec 2011, 09:20 PM
I have a user control with several RadComboBoxes.  My user control implements IScriptControl. It also has properties to allow the person using the control to set the handlers for events I am raising from the user control.  I would like to handle the events from the comboboxes in my userControl javascript prototype, but I'm having an issue with this code:

_onDropDownSelectedIndexChanged: function(source, e){
    if(!this._events) return;
    var handler = this._events.getHandler("selectedIndexChanged");
    if(handler)
    handler(this,e);
}

The problem is the context of "this".  I had expected it to be my prototype object, but it's not even though this is defined within my prototype.

Here's my hook up in my initialize:
ddlStore.add_selectedIndexChanged(this._onDropDownSelectedIndexChanged);

Any help or examples would be greatly appreciated.

2 Answers, 1 is accepted

Sort by
0
Troy
Top achievements
Rank 1
answered on 21 Dec 2011, 10:03 PM
I've somewhat resolved this, but was hoping for a more elegant solution.  Here's what I did:
I just get the parent of the source in the event handler, which is my user control.

_onSelectedStoreChanged: function (source, e) {
        var storeSelector = source.get_parent();
        if (!storeSelector._events) return;
        var handler = storeSelector._events.getHandler("selectedDateChanged");
        if (handler)
            handler(storeSelector, Sys.EventArgs.Empty);
    }
0
Ivana
Telerik team
answered on 26 Dec 2011, 05:43 PM
Hi Troy,

Could you send us a support ticket on this matter? Please attach a sample project with the issues isolated in it, so we will be able to troubleshoot them locally and hopefully come to a more elegant solution.

Kind regards,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ComboBox
Asked by
Troy
Top achievements
Rank 1
Answers by
Troy
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or