Results 1 to 10 of 10

Thread: Ext.Class constructor issue

  1. #1
    Sencha User nak1's Avatar
    Join Date
    Jan 2008
    Posts
    319
    Answers
    2

    Default Ext.Class constructor issue

    Guys,

    I've got this singleton class that I'm using as a global object. I'm running into an issue, however, when I try to call the constructor, the config comes in as undefined.

    Thoughts?

    Code:
    Ext.define('Resource.global.Config',{
    	extend:'Ext.Class',
    	singleton:true,
    	config:{
    		file_subtype:[],
    		site_url:'',
    		file_type:[],
    		file_type_all:[],
    		checkFileUploadSize:'',
    		max_file_size:750,
    		is_external:true,
    		is_company_share_holder:false,
    		is_company_manager:false,
    		clientid:0,
    		client:{},
    		ajax_path:'/ajax/',
    		ajax_interface_gather:'ajax_interface_gather.cfm',
    		ajax_interface_post:"ajax_interface_post.cfm",
    		comm_menu:[],
    		comm_category:[],
    		state:'',
            states:'',
            weight_unit:[],
            height_unit:[],
            resource_conditions:'',
            pos_resource:false,
            company_tile:'',
            military_service:'',
            education_level:'',
            system_configuration_setting:'',
    		image_upload_url:'',
    		resources_import:[]
    	},
    	
        constructor: function(config) {
        	this.initConfig(config);
            return this;
        }
    });
    No longer a Newbie

  2. #2
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    2,372
    Answers
    20

    Default

    You shouldn't extend Ext.Class.

    You can extend Ext.Base, but it's not needed.

  3. #3
    Sencha User nak1's Avatar
    Join Date
    Jan 2008
    Posts
    319
    Answers
    2

    Default

    What's the best approach to make a global config object for a package?
    No longer a Newbie

  4. #4
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    2,372
    Answers
    20

    Default

    Quote Originally Posted by nak1 View Post
    What's the best approach to make a global config object for a package?
    You can put global configs in a singleton which can be required it in any class. I think this was a good idea.

  5. #5
    Sencha User nak1's Avatar
    Join Date
    Jan 2008
    Posts
    319
    Answers
    2

    Default

    When I use Ext.Base config is still undefined. Seems to me that this is a bit of a bug (regardless of whether or not I should be using this or not).
    No longer a Newbie

  6. #6
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    2,372
    Answers
    20

    Default

    Can you simplify your example and create a bare minimum fiddle which still demonstrates the problem?

  7. #7
    Sencha User nak1's Avatar
    Join Date
    Jan 2008
    Posts
    319
    Answers
    2

    Default

    Sure, here's a link: https://fiddle.sencha.com/#fiddle/11oi

    Open your console and take a look at the output of config.
    No longer a Newbie

  8. #8
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    2,372
    Answers
    20

    Default

    I simplified the fiddle and it works fine. Can you modify the simpler fiddle to show the issue?

  9. #9
    Sencha User nak1's Avatar
    Join Date
    Jan 2008
    Posts
    319
    Answers
    2

    Default

    But in your fiddle the config is still undefined when it comes into the constructor. Is that just not pulling in the config?
    No longer a Newbie

  10. #10
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    2,372
    Answers
    20

    Default

    It's undefined because you are not passing config values to the singleton. I didn't see a singleton which would accept dynamic configuration values to be used upon creation.

    See, the 2nd example where a config is passed to the constructor.

    https://fiddle.sencha.com/#fiddle/11oj

Similar Threads

  1. Problem with class constructor
    By schuc in forum Ext: Q&A
    Replies: 4
    Last Post: 10 Oct 2012, 12:37 AM
  2. Replies: 1
    Last Post: 27 Mar 2012, 12:16 PM
  3. Extended Class: Is Not A Constructor
    By Chris55 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 1 Oct 2009, 11:57 AM
  4. createInterceptor on an Ext class constructor
    By mankz in forum Community Discussion
    Replies: 35
    Last Post: 15 Jan 2009, 10:47 AM
  5. class constructor is not a construtor?
    By Simon Wibberley in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 15 May 2007, 4:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •