Adding behavior to an existing component using plugins

Plugin is another mechanism by which we can enhance/customize the behavior of an existing component. The new behavior is effective only if the plugin is added to the component. Otherwise, the base behavior remains intact. In this recipe, we will understand how to create a new plugin and use that on an existing component.

Getting ready

Make sure that you have set up your development environment by following the recipes outlined in Chapter 1.

How to do it...

Carry out the following steps:

  1. Create and open a new file PhotoAlbumPlugIn.js and paste the following code in it:
    Touch.book.ux.PhotoAlbumPlugIn = Ext.extend(Ext.util.Observable, { init: function(viewCmp) { viewCmp.tpl = new Ext.XTemplate( '<tpl ...

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.