Results 1 to 5 of 5

Thread: Howto access loading Class out of Mixins Function (this; parent; ...?)

  1. #1
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6

    Default Howto access loading Class out of Mixins Function (this; parent; ...?)

    Maybe I am only confused and need simple clearing?...:

    If I want to call a Mixins Function I know:

    this.mixins.mixinname.mixedinFunction();
    but if I am within mixedinFunction, how to access the old this ?

    "parent" or "this" is not the right way I think.

  2. #2
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6

    Default

    if this is right ... I have done a mistake and got confised this way.

  3. #3
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6

    Default

    I found an early discussion in forum:
    http://www.sencha.com/forum/showthre...within-a-mixin

    but for me it isn't clear cut - mitchellsimoens talk about:
    So the mixin can reference the parent class via the scope and the parent class can reference the mixin either by the this.mixins object or the things the mixins place on the parent class.
    what does the line

    PHP Code:
    this.mixins.mymixin.foo.call(this); 
    do ?

    Is the call(this) on mixed in method what he talk about saying "scope" ?

    If I try this for my needs on a predefined string param (not a function) it causes in a value "undefined".

    So based on the Example in the old thread - how has to look a call of a param instead - for example ?!

    If I do out of mixins.mymixin.foo a call to Parent Classes function called this.parentClassTestFunction (because in my opinion all methods are in one scope) I get

    TypeError: 'undefined' is not a function (evaluating 'this.parentClassTestFunction()')
    In my way to expect clear to only logical way to expect how it should work:

    Within mixins.mymixin.foo:
    PHP Code:
    console.log(this.parentparam// should pull out the value is stored in mixin loading classes param parentparam 
    Same for function-calls to mixin loading Class within mixins function.

    Please do a clear clarification to this FAQ (I think) :-)

    If he mean by saying "reference the parent class via the scope" you have to send the Scope to this.mixins.mymixin.foo(this) it would nullify the sense of mixins for me. It blows up memory needs only to be able working with.
    If he mean this - please discuss how to do this a better way :-)

  4. #4
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6

    Default No Idea ?

    motivated to bring Question up to first page ... once more asking:

    Is there not a good Answer to this good Question ?

    Thanks for Thinking about

  5. #5
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448
    Answers
    3997

    Default

    Code:
    this.mixins.mymixin.foo.call(this);
    What this does is gets the mixin class by name (mymixin in this case) and simple calls the foo method with scope of the parent class. This is usually used when the parent class has a same method name as the mixin and you need to call the mixin method.

    For example. Ext.util.Observable is a mixin in Ext.AbstractComponent. Each class has a constructor method but Ext.AbstractComponent needs to call the constructor method of Ext.util.Observable so Ext.AbstractComponent does:

    Code:
    me.mixins.observable.constructor.call(me);
    The me variable is a local variable assigned to this and this code is in the initComponent method of Ext.AbstactComponent.

    If you are within a method of the mixin, the scope should be of the parent class. A mixin's methods and properties are set onto the parent class unless the parent class has a member with the same name (the mixin will not overwrite the parent class)
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Posting Permissions

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