Agile Development. more fun. less stress.

Ext.dataview.DataView and setEmptyText

I’m currently developing a Sencha Touch application and therefore I use Sencha Touch Beta2.

I had to change the emptyText property of a Ext.dataview.List via setEmptyText() and ran into a little bug which adds another emptyTextCmp component inside the list’s element rather than update the existing one.

So I came up with an override for this. maybe this helps someone out there too.

The function code we are going to override is Ext.dataview.Dataview#updateEmptyText:

Original function code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
updateEmptyText: function(newEmptyText) {
        var me = this;
        if (newEmptyText) {
            me.emptyTextCmp = me.add({
                xtype: 'component',
                cls: me.getBaseCls() + '-emptytext',
                html: newEmptyText,
                hidden: true
            });
        }
        else if (me.emptyTextCmp) {
            me.remove(me.emptyTextCmp, true);
            delete me.emptyTextCmp;
        }
    }

Override:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Ext.define('My.override.of.dataview.DataView', {
    override: 'Ext.dataview.DataView',
   
    updateEmptyText: function(newEmptyText){
        var me = this;
        if (newEmptyText) {
            if (me.emptyTextCmp){
                me.emptyTextCmp.setHtml(newEmptyText);
            } else {
                me.emptyTextCmp = me.add({
                    xtype: 'component',
                    cls: me.getBaseCls() + '-emptytext',
                    html: newEmptyText,
                    hidden: true
                });
            }
        } else if (me.emptyTextCmp) {
            me.remove(me.emptyTextCmp, true);
            delete me.emptyTextCmp;
        }
    }
});

Sencha Touch (ExtJS) – Problems with Ext.TabPanel when using ‘cardswitch’ event

Currently I’m writing a mobile application based on Sencha Touch 1.1.0.
When I was using the ‘cardswitch’ event of the TabPanel class I noticed that the API docs show a wrong number of arguments:

Description in API docs:

1
cardswitch : ( Ext.Container this, Ext.Component newCard, Ext.Component oldCard, Number index, Boolean animated )

This is how it is implemented:

1
cardswitch : ( Ext.Component newCard, Ext.Component oldCard, Number index, Boolean animated )

Maybe this is helpful to some developers out there.

Rails: undefined method ‘[]’ for #<Enumerable::Enumerator>

I was moving an older Rails app to a new server when I encountered this error. This gives a good description of what was going on and shows how to fix it:
http://groups.google.com/group/attachment_fu/browse_thread/thread/502dd4504a59c84d.
Ruby 1.8.7 and acts_as_attachment didn’t get along with each other in my case. However, there’s a typo where .first == ‘/’ is replaced.
starts_with(‘/’) should be starts_with?(‘/’).
That’s no rocket science but could be useful for noobs (on Rails).