Get text box input

I have a text box in Sencha Touch 2 and a button. I would like to get a text box input when a button is clicked. I tried this with Ext.ComponentQuery, but it did not work. Ask someone an example how to do this?

{ xtype: 'textfield', cls: 'inputfields', id: 'title', }, { xtype: 'button', ui: 'action', name: 'textfieldButton', handler : function(){ // what should go here ? } } 
+4
source share
2 answers

My way to do this is Ext.getCmp('title').getValue();

Also see Docs ( Docs API ). They are really helpful.

+4
source

You can do:

 var value = Ext.ComponentQuery.query('#title')[0].getValue(); // test by writing in console console.log(value); 

TIP 1: It is useful to have a Sencha API link open all the time when you use this structure (similarly for any other framework, programming language, etc.). For speed, I suggest downloading it.
TIP 2: In Chrome, Ctrl + Shift + I for developer tools; you can access the console.

+2
source

Source: https://habr.com/ru/post/1444206/


All Articles