Moltiple views, one model

oscar's Avatar

oscar

16 Mar, 2010 06:30 PM

Hi,

I'm adding views at run time. each one is support to have a module and a mediator. I have two problems.

1) The mediators are getting the events dispatched from all views (different instance of the same view).
2) Looks like I have just one model for all the instances of the view.

in my context, I'm doing this:

injector.mapSingleton( MyViewModel );

mediatorMap.mapView(MyView, MyViewMediator);

and My events are not bubbling.

should I do "conect" the mediator and the models in a different way?

tks.

  1. 1 Posted by oscar on 16 Mar, 2010 06:35 PM

    oscar's Avatar

    Quick note; when I want to create a view of that component, I'm just adding it to the display list.

  2. Support Staff 2 Posted by Till Schneidere... on 16 Mar, 2010 06:36 PM

    Till Schneidereit's Avatar

    If you want each of your mediators to have a unique instance of
    MyViewModel, you'll have to change "injector.mapSingleton" to
    "injector.mapClass". That way, the injector creates a new instance for
    each injection.

    As for the events, that doesn't sound right. Can you maybe create an
    example of this happening that doesn't contain any of your proprietary
    code? Without that, it's hard to tell what's going on.

  3. 3 Posted by oscar on 16 Mar, 2010 07:05 PM

    oscar's Avatar

    Yes, the "injector.mapClass" does the trick. How can I access the model I need from a command?

    Should I insert the model into the mediator and have the mediator to listen for the events and interact with the models?

  4. Support Staff 4 Posted by Joel Hooks on 16 Mar, 2010 07:10 PM

    Joel Hooks's Avatar

    One approach for the command would be to have the model as a parameter to the event that triggers the command, otherwise you will need to create a registry of some sort (a model of models with unique identifiers)

  5. 5 Posted by oscar on 17 Mar, 2010 11:41 PM

    oscar's Avatar

    tks.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac