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

[Solved] How to globally open ComboBox controls on click event

2 Answers 112 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeff
Top achievements
Rank 1
Jeff asked on 06 Nov 2011, 04:11 PM
Hi - I'm trying to setup a behavior in our application that fires the ComboBox open() function on click for all ComboBoxes in the document.   I'm able to hook up the open function individually using the field's jquery ID with code from the Telerik demo page, but I'd like to generically wire up all combo box controls on the document.ready() function, and I'm having trouble figuring out the jquery navigation. 

For example:

$(document).ready(function () {
    // Hook up the combo box click method
    $('.t-combobox').bind('click', function (e) {
      // ** this next line is wrong - I can't find the correct relation between e and data("tComboBox")
      e.data("tComboBox").open();
  
      // prevent the click from bubbling, thus, closing the popup            
      if (e.stopPropagation) e.stopPropagation();            
      e.cancelBubble = true;       
    });
});

Does anyone know the correct way to get to the tComboBox data element from the event?

(I know you can get similar behavior by using the Telerik control's OpenOnFocus(), but I don't want them to open when the user is just tabbing through the fields - only when clicked)

Thanks!

Jeff

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 07 Nov 2011, 10:44 AM
Hello Jeff,

 
The combobox client object is attached to the hidden INPUT element of the ComboBox. You will need to use something like this to achieve your goal:

$(document).ready(function () {
    // Hook up the combo box click method
    $('.t-combobox').bind('click', function (e) {
      $(e.currentTarget).find("input:hidden").data("tComboBox").open();
   
      // prevent the click from bubbling, thus, closing the popup           
      if (e.stopPropagation) e.stopPropagation();           
      e.cancelBubble = true;      
    });
});


Greetings,
Georgi Krustev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Jeff
Top achievements
Rank 1
answered on 07 Nov 2011, 02:18 PM
Works perfectly.   Thanks again, Georgi!
Tags
ComboBox
Asked by
Jeff
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or