Results 1 to 4 of 4

Thread: How can I explicitly set parent viewModel to a component I instantiate?

  1. #1
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,295
    Answers
    16

    Default How can I explicitly set parent viewModel to a component I instantiate?

    I have a component that is added to a different hierarchy that it's natural parent, actually it's even added by adding to element directly instead of container.add.

    How can I tell this component I instantiate which viewModel it should do look-up against?

  2. #2
    Ext JS Premium Member
    Join Date
    Jun 2008
    Posts
    21
    Answers
    2

    Default

    I'm not sure if I understand the question correctly, but I'll take a stab.

    If you add a component (let's call it subcomponent) that doesn't have a viewModel defined into another component ("parent component") that does have a viewModel defined, the subcomponent binds should automatically pick up data from the parent component's viewModel. My understanding is that those binds cascade downward through the dom. I assume that would mean that the directly added component bindings should work too, although I've never tried that.

    Good Luck!
    Last edited by jpeckham; 6 Feb 2015 at 12:23 PM. Reason: Formatting

  3. #3

    Default

    Did you even read the question? He said he wants to tie a component's viewmodel to an arbitrary other one, regardless of the dom or component hierarchy.

  4. #4
    Ext JS Premium Member
    Join Date
    Jun 2008
    Posts
    21
    Answers
    2

    Default

    Quote Originally Posted by sarimarton View Post
    Did you even read the question? He said he wants to tie a component's viewmodel to an arbitrary other one, regardless of the dom or component hierarchy.
    I did say that I was not sure I understood the question. I'm not sure if it was your intent, but your response appears quite rude to someone who was trying to help another person out. This is the Sencha forum, not "AngrierJS". Furthermore, you're replying to an old post when most of us were still learning mvvm using Sencha products and the documentation at the time was sparse (it is now much better and clearer). I thought my response might be helpful either for the OP or others who stumbled upon this trying to grok viewModels.

    To answer the OPs question, now that you've clarified his question for him, I would guess this is the answer he (and probably you) are seeking:
    https://www.sencha.com/forum/showthread.php?288780

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
  •