PDA

View Full Version : How to trigger an event upon select of form.ComboBox?



don1234
12 Sep 2012, 4:55 PM
Hi,

The form.ComboBox is very handy for autosuggest. Now, I'd like to take a step further, that is, upon selection, trigger another event such as submit the form. Is it doable with Ext 2.2? If so, how?

Thanks in advance.

sword-it
12 Sep 2012, 10:16 PM
HI!
i am wondering you have posted your thread in sencha touch 2.x forum and mentioned Ext 2.2 in description??

if you are using sencha touch, you may use selectfield instead of combo.

if you are using ExtJs 2.x versions...you may use select event for your combo(Fires when a list item is selected) and do whatever you want!
check this:-
http://docs.sencha.com/ext-js/2-3/#!/api/Ext.form.ComboBox-event-select

don1234
13 Sep 2012, 5:19 AM
oops, sorry wasn't paying enough attention about the forum name...

could you showed a sample of select use in relation to form.ComboBox?
like a select method similar to id or mode OR via listeners something?

many thanks.

sword-it
13 Sep 2012, 5:38 AM
Sample for you to attach select on your form.combobox:-


name:'myCombo',
listeners:{
select:function(cmb,rec,index){
// do whatever you want here
}
}

don1234
13 Sep 2012, 6:24 AM
Thank you for the sample code.

Here's what I added to the ComboBox interface, parallel in usage to id method, but code location-wise, right after the id method.
listeners:{
select:function(cmb,rec,index){
alert('action upon select');
document.forms[0].submit()}
},
// next, mode method

Outcome: no error msg, and yet it does not do anything, tested with Firefox 15 with Firebug on. What am I missing here?