Results 1 to 3 of 3

Thread: Referencing components

  1. #1

    Default Referencing components

    I've been using Ext for about two years now and I can't say enough good things about it. So first off, thanks to all the developers involved in the project.

    The main issue I have with my Ext code is in referencing components. Javascript scoping still confuses the hell out of me at times and I have a hard time resolving what "this" means in a given context. So to circumvent using the "this" keyword, the most common methods I use are supplying an id for use with Ext.getCmp() or assigning the component to a variable which can possibly lead to scoping issues if you aren't careful. Both methods just end up feeling clunky to me. It's weird having a bunch of Ext.getCmp()'s at the beginning of an anonymous event delegate and seems like there should be a cleaner way to reference components using the parent/items chain.

    Also, I'm not sure of the best way to write/reference a component in a factory pattern. Supplying an id to a factory created component seems like it would make Ext.getCmp() ambiguous when more than one component is created (with the same id). So my solution is to create explicit references within the function's scope for every single component that I need to reference.

    Does any of this make sense? Is there a best practice for component resolution or a more generic way to reference components?

    Thanks,

    Josh

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Have you seen Jays screencast on the matter?

  3. #3

    Default

    That hit the nail on the head. The itemId pattern seems to act like a scoped Ext.getCmp which is very useful. Thanks for the help. The this.property pattern seems the cleanest and my favorite, but requires a bit heavier object than what is sometimes required.

Similar Threads

  1. Form Element Referencing
    By simon_b in forum Sencha Touch 1.x: Discussion
    Replies: 5
    Last Post: 25 Oct 2010, 11:38 PM
  2. Referencing some items each other
    By attu in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 30 Sep 2010, 6:01 AM
  3. Referencing components in containers
    By dlipski in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 13 Nov 2009, 7:41 AM
  4. Referencing custom functions in extended components
    By nxn in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 11 Mar 2009, 6:42 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
  •