How do you dynamically add to the model?

2 posts, 0 answers
  1. Steve
    Steve avatar
    1871 posts
    Member since:
    Dec 2008

    Posted 23 Jan 2013 Link to this post

    Setup: I have a master model, and my page has a bunch of widgets on it.

    So I want to have the widgets powered by MVVM instead of wiring everything up manually in jQuery.

    Here's the sample

    So what am I doing wrong here?...why is the event not firing?
  2. Holger
    Holger avatar
    78 posts
    Member since:
    Nov 2012

    Posted 24 Jan 2013 Link to this post

    Hi Steve,

    I guess the problem is that layoutViewModel.gadgets.widget1 is not initialized at the time when the HTML is loaded, so the binding will not work. After adding an event handler to the root model and calling gadgets.widget1.doneloading inside it everything works fine.

    Please have a look at the modified sample:

Back to Top