Results 1 to 4 of 4

Thread: Extending Ext.Element and base

  1. #1

    Default Extending Ext.Element and base

    After reading the tutorials on extending objects in Ext I'm still confused. Could someone explain or provide code on how to create a function which extends both Ext and Ext.Element?

    I'd like to be able to call Ext.myfunction and have it work with the get function like Ext.get("element").myfunction.

    Thanks

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256

    Default

    Code:
    Ext.Element.prototype.myFunc = function()
    {
       console.log(this.dom.innerHTML);
    };
    
    Ext.onReady(function()
    {
       Ext.get('foo').myFunc();
    }
    );
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3

    Default

    Thanks for the quick reply, but this doesn't seem that it'd support Ext.myFunc() as well.

    The code I've tried was:

    Ext.myFunc = function() {
    //something
    }

    Ext.Element.prototype.myFunc = function() {
    //sets the configuration object and calls Ext.myFunc
    }

    The issue is the function makes an Ajax call and when making multiple calls at once the config references are lost.

  4. #4
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256

    Default

    Code:
    Ext.myFunc = function()
    {
       alert('foo');
    };      
    Ext.Element.prototype.myFunc = Ext.myFunc;
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

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