Results 1 to 4 of 4

Thread: Ext.define is not a function

  1. #1
    Sencha User
    Join Date
    May 2016
    Posts
    9
    Vote Rating
    0
      0  

    Default Ext.define is not a function

    In a Sencha Touch application I have defined some classes in a js file in the Resources section.
    Like that:
    Code:
    Ext.define('Contact', {
        Insert: function() {
            //Code...
        },
        Delete: function() {
            //Code...
        }
     });
    Connecting locally, with Architect running, the application runs properly, but if I 'Build web app' and I publish the application, then I get the error: 'Ext.define is not a function'.
    How can I fix?

    Architect version: 3.5.1.348
    Framework: Sencha Touch 2.4.x
    I tried to edit the file app.json to change the order of loading js resource, but in vain because it is regenerated every time you save.
    Thanks for any suggestions.

  2. #2
    Sencha User
    Join Date
    May 2016
    Posts
    9
    Vote Rating
    0
      0  

    Default

    Today I found that the problem lies elsewhere. I get the error: 'Ext.define is not a function' at startup, but I realized that my class is defined anyway.
    The problem is that I add my class as an attribute of another class and this works in debug, whereas the attribute is undefined after publishing.

    Code:
    this.getMainNavigationView().push({
        xtype: 'Container',
        myProperty: Ext.create('Contact')
    });
    Is it a bug? Is there a workaround to solve the problem?

    I tried to add attribute doing:
    Code:
    Ext.apply(theContainer, {myProperty: Ext.create('Contact')});
    This works, but I need the property is present in the initialize of theContainer, so this doesn't solve.
    Thanks to those who will help me.

  3. #3
    Sencha User
    Join Date
    Sep 2014
    Location
    Central Europe
    Posts
    795
    Vote Rating
    52
      0  

    Default

    In the class/file where you use Ext.create:

    Code:
    this.getMainNavigationView().push({
        xtype: 'Container',
        myProperty: Ext.create('Contact')
    });
    Add to the requires array the class Contact.

    http://stackoverflow.com/a/10989861/1768843

  4. #4
    Sencha User
    Join Date
    May 2016
    Posts
    9
    Vote Rating
    0
      0  

    Default

    I tried to add the class Contact to the requires array, but I keep getting the error: 'Ext.define is not a function', however the application works the same.

    I solved the problem of adding an attribute to a class, defining a new class, so if I wrote:

    Code:
    this.getMainNavigationView().push({
        xtype: 'Container',
        myProperty: Ext.create('Contact')
    });

    Only it works with Architect running, instead writing:


    Code:
    Ext.define('foo', {
        extend: 'MyApp.Container',
        myProperty: Ext.create('Contact')
    }
    this.getMainNavigationView().push(Ext.create('foo'));
    This also works after publishing the application.

    Thanks for the support.

Similar Threads

  1. How can I define a function in an XTemplate
    By blomasky in forum Sencha Architect 3.x: Q&A
    Replies: 1
    Last Post: 21 Aug 2014, 10:52 AM
  2. Ext.define callback function
    By rcranley in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 20 Feb 2014, 10:03 PM
  3. Ext.extend to Ext.define function?
    By Vinni in forum Ext: Discussion
    Replies: 1
    Last Post: 11 Dec 2012, 12:54 PM
  4. can i self define a function in controller?
    By linuxyf in forum Sencha Touch 2.x: Discussion
    Replies: 3
    Last Post: 6 Sep 2012, 12:59 AM
  5. Define event for validator function
    By extjser12 in forum Ext: Q&A
    Replies: 4
    Last Post: 19 Feb 2012, 11:52 AM

Tags for this Thread

Posting Permissions

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