Results 1 to 8 of 8

Thread: 0.96 defer problem!?

  1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    30
    Vote Rating
    0
      0  

    Default 0.96 defer problem!?

    Hi,

    since 0.96 the following code with 'defer' isn't working any more:

    Code:
    setThisText.defer(1000, this, ['btnA', cont]);
    The function called sets the button's text:

    Code:
    function setThisText(thisID, thisTxt) {
            Ext.getCmp(thisID).setText(thisTxt);
        }
    With 0.95 this worked. What is the problem now?

    Btw, I read that 'Ext.getCmp(id)' isn't a good approach. What is the best way to access your components then?

    Thanks

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,215
    Vote Rating
    1008
      0  

    Default

    We decided to stop augmenting the prototype with custom functions so that Ext will always play nicely with other libraries. One of the unfortunate trade-offs is now you need to use:

    Code:
    Ext.defer(setThisText, 1000, ......);
    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
    Sencha User
    Join Date
    Sep 2010
    Posts
    30
    Vote Rating
    0
      0  

    Default

    Thanks, it works again!

  4. #4
    Sencha User
    Join Date
    Jul 2010
    Location
    Paris, France
    Posts
    257
    Vote Rating
    0
      0  

    Default

    What about Ext.getCmp ? How bad is it and why ?

  5. #5
    Sencha User
    Join Date
    Sep 2010
    Posts
    30
    Vote Rating
    0
      0  

    Default

    It's been in the thred
    panel content under toolbar
    where jgarcia wrote:
    ... i highly suggest not developing your apps depending on Ext.getCmp();
    .
    And in
    0.96 itemtap problem
    mitchellsimoens says:
    Ext.getCmp should be used for development only
    .

    Can anybody explain this issue a little bit?

  6. #6
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,215
    Vote Rating
    1008
      0  

    Default

    Ext.getCmp is not ~bad~, it's just a tool. If you use it in the wrong way, then it is bad. As the name suggests, it returns you a component based on some global identifier. This means every identifier for every component needs to be unique.

    Let's say you're writing a class, some panel that you plan to use in multiple spots in your application:

    Code:
    MyPanel = Ext.extend(Ext.Panel, {
        // ...
        new Ext.List({
            id: 'foo'
        });
        new Ext.Carousel({
            id: 'bar'
        });
    });
    What happens when you create a second instance? It's like a division by zero! Similarly, one could argue it also breaks encapsulation, since you just have this global dictionary of objects.

    If you're writing applications, you'll come up with better and neater ways to reference your components, because you'll see that getCmp isn't really suitable in all cases. But it's not bad.
    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.

  7. #7
    Sencha User
    Join Date
    Jul 2010
    Location
    Paris, France
    Posts
    257
    Vote Rating
    0
      0  

    Default

    Ok everything you said make sense... Thank you. But actually, why should one use ids for something that he will reuse ?
    What about the fact that a "id" is unique ?

    Well, things are messed up now

  8. #8
    Sencha User
    Join Date
    Sep 2010
    Posts
    30
    Vote Rating
    0
      0  

    Default

    Thanks for your quick reply and explanation. I think I understand so far. But could you please give us also an example on how the ...
    neater ways to reference your components
    ... could look like?

Similar Threads

  1. problem with defer
    By willi in forum Sencha Touch 1.x: Discussion
    Replies: 6
    Last Post: 22 Sep 2010, 1:39 AM
  2. [DEFER-482][2.x/3.x] TreePanel Node Highlight Problem
    By crashedsnow in forum Ext 3.x: Bugs
    Replies: 7
    Last Post: 22 Mar 2010, 8:09 AM
  3. Problem with defer..
    By boydapa3 in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 15 Apr 2007, 8:52 PM
  4. Problem with defer..
    By boydapa3 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 15 Apr 2007, 3:52 PM

Posting Permissions

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