Overriding a component behavior
This recipe will show us how to override an existing behavior of an existing component and use the modified behavior in the code.
Getting ready
Make sure that you have set up your development environment by following the recipes outlined in Chapter 1.
How to do it...
- Create and open a new file named
PhotoAlbumOverride.js
and paste the following code in it:Ext.override(Touch.book.ux.PhotoAlbum, { loadData : function(data) { if (this.store.getCount() > 0) { Ext.Msg.alert('Info', 'The view is already loaded with data. No action will be performed.'); } else { this.store.loadData(data); } } });
- Update the
index.html
file. We will use the existingch06_13.js
file. - Deploy and access it from the browser. You may also run it using ...
Get Sencha Touch Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.