- Sencha Touch Tutorial
- Sencha Touch - Home
- Sencha Touch - Overview
- Sencha Touch - Environment
- Sencha Touch - Naming Convention
- Sencha Touch - Architecture
- Sencha Touch - MVC Explanation
- Sencha Touch - First App
- Sencha Touch - Build Application
- Sencha Touch - Migration Steps
- Sencha Touch - Core Concepts
- Sencha Touch - Data
- Sencha Touch - Theme
- Sencha Touch - Device Profile
- Sencha Touch - Dependencies
- Environment Detection
- Sencha Touch - Events
- Sencha Touch - Layout
- Sencha Touch - History & Support
- Sencha Touch - Upload & Download
- Sencha Touch - View Components
- Sencha Touch - Packaging
- Sencha Touch - Best Practice
- Sencha Touch Useful Resources
- Sencha Touch - Quick Guide
- Sencha Touch - Useful Resources
- Sencha Touch - Discussion
Sencha Touch - Class System
Sencha Touch is a JavaScript framework, which has functionalities of object-oriented programming. Sencha Touch class system is based on Ext JS 4 standards. Ext is the namespace which encapsulates all the classes in Sencha Touch.
Defining a Class in Sencha Touch
Ext provides more than 300 classes, which we can use for various functionalities.
Ext.define() is used for defining classes in Sencha Touch.
Syntax
Ext.define(class name, class members/properties, callback function);
Class name is the name of class according to the app structure. For example, appName.folderName.ClassName studentApp.view.StudentView.
Class properties/members defines the behavior of class.
Callback function is optional. It is called when the class has loaded properly.
Example of Sencha Touch class definition
Ext.define(studentApp.view.StudentDeatilsGrid, { name: 'StudentName, read: function(bookName){ console.log(this.name +’is reading ’bookName); } });
Creating Objects
As other OOPS based languages, we can create objects in Sencha Touch as well.
Way to create objects in Sencha Touch using new keyword −
var studentObject = new student(); studentObject.read(‘History’);
Console output will be StudentName is reading history.