View Full Version : Correct syntax and location for a valid sencha touch (js) function?

24 Nov 2010, 4:29 PM
Hi! I'm new with sencha touch and javascript, I'm working in this app, and I'd like to include a new function in the .js file.

It would be very helpful for me if you point me where to put my function, and if it has a correct syntax.

This is the function I want to include:

//this function will be called every time the server sends a notification
function tapped (numberOfTaps){
//'notificaciones' is the name of my button

And this is the code of my js file:

kiva.views.LoanFilter = Ext.extend(Ext.form.FormPanel, {
ui: 'green',
cls: 'x-toolbar-dark',
baseCls: 'x-toolbar',

initComponent: function() {


Ext.apply(this, {
defaults: {
listeners: {
change: this.onFieldChange,
scope: this

layout: {
type: 'hbox',
align: 'center'

items: [
xtype: 'selectfield',
name: 'gender',
prependText: 'Gender:',
options: [
{text: 'Both', value: ''},
{text: 'Male', value: 'male'},
{text: 'Female', value: 'female'}
xtype: 'selectfield',
name: 'sector',
prependText: 'Sector:',
options: [
{text: 'All', value: ''},
{text: 'Club Campestre', value: 'campestre'},
{text: 'Tecnotam', value: 'tecnotam'} ]
name: 'notificaciones',
xtype: 'button',
ui : 'decline',
text: '0'
xtype: 'spacer'


kiva.views.LoanFilter.superclass.initComponent.apply(this, arguments);

* This is called whenever any of the fields in the form are changed. It simply collects all of the
* values of the fields and fires the custom 'filter' event.
onFieldChange : function(comp, value) {
this.fireEvent('filter', this.getValues(), this);

Ext.reg('loanFilter', kiva.views.LoanFilter);

Thank you very much!

25 Nov 2010, 5:03 PM
What exactly are you looking to register a handler on? Eduardo, you really need to consider learn JavaScript before using Sencha Touch effectively.