1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    59
    Vote Rating
    0
    dddesign is on a distinguished road

      0  

    Default custom function in Ext.application not working after build package

    custom function in Ext.application not working after build package


    I need a global variable in my views and store. after searching the forum I found this solution:

    Code:
    Ext.application({
        name: 'PhotoMoonTool',
        ....
        getSection: function() {
            url_args = window.location.toString().split("?");
            if (url_args[1]) {
                url_args = Ext.Object.fromQueryString(url_args[1]);
                return url_args.section + '/';
            } else {
                return '';
            }
        }
        ....
    });
    and in views I use it as this:
    Code:
           ....
           itemTpl: [
                '<img src="http://www.moontools.ch/photo-moon-tool/'+ PhotoMoonTool.app.getSection() +'images/{folder_name}/{img_name}001{name_zusatz}.jpg" >' +
           ]
           ....
    this is working, check here:
    http://mobile.moontools.ch/photomoontool1/
    and http://mobile.moontools.ch/photomoontool1/?section=manu

    but if I build a webapp ("sencha app build package" or "sencha app build production") I get some errors (getSection is not defined). see here:
    http://mobile.moontools.ch/package and
    http://mobile.moontools.ch/production/ (this is production)

    any hint how I can solve this?
    thanks a lot. j

  2. #2
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    That's because your classes are defined before the application actually gets instantiated. You should elevate such required methods into a utils namespace. Include that before any other classes, and it will work fine. I did this for both the SenchaCon 2011 and DiscoverMusic applications.

Thread Participants: 1