This recipe will show us how to override an existing behavior of an existing component and use the modified behavior in the code.
Make sure that you have set up your development environment by following the recipes outlined in Chapter 1.
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 the emulator. You will see the following screen: