Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Feb 2011
    Vote Rating
    mj2025 is on a distinguished road


    Default Custom methods (functions) for an item/object

    Custom methods (functions) for an item/object


    Consider the following example code snippet (worked fine in PR3 and previous versions of Sencha Touch I/II)

        icon: 'resources/images/icon.png',
        glossOnIcon: false,
        tabletStartupScreen: 'resources/images/tablet_startup.png',
        phoneStartupScreen: 'resources/images/phone_startup.png',
        requires: [
        launch: function() {
                xtype: 'tabpanel',
                id: 'root',
                items: [
                        id: 'example',
                        title: 'Home',
                        iconCls: 'home',
                        html: [
    '<img src="http://staging.sencha.com/img/sencha.png" />',
    '<h1>Welcome to Sencha Touch</h1>',
    "<p>You're creating the Getting Started app. This demonstrates how ",
    "to use tabs, lists and forms to create a simple app</p>",
    '<h2>Sencha Touch (2.0.0)</h2>'
                        customFn1: function () { alert('customFn1'); }
            var panel = Ext.Viewport.getComponent('root').getComponent('example');
            panel.customFn1(); // <-- THIS FAILS

    At the moment the above fails since starting with (at least) Beta 2 ST 2.0 Release. It turns out that customFn1 is not applied to the 'example' instance, but its rather copied to the example.config attribute. I do have a workaround, but was wondering if there is any 'legal/supported' way to make this work as I have loads of code that use this approach. Please note that in previous versions the 'scope' was the item itself which was very handy.

  2. #2
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Redwood City, California
    Vote Rating
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough



    This will not work without compatibility mode turned on. If you want to do this type of thing, you would need to access the config object like you mentioned. It's not something we encourage doing.

    Sencha Inc

    Jamie Avins


Thread Participants: 1