petermichaux / maria

The MVC framework for JavaScript applications. The real MVC. The Smalltalk MVC. The Gang of Four MVC.
BSD 2-Clause "Simplified" License
764 stars 51 forks source link

Trigger Event on another controller ... #79

Closed jamesladd closed 10 years ago

jamesladd commented 10 years ago

I have a reusable view class that is a menu and I want some ui actions captured by the menu items controller to be raised on another view.

How can I do this?

It is like I want a uiAction handler to be invoked from my Controller.

petermichaux commented 10 years ago

I cannot imagine a situation where you would want to do this. I think the design of the application needs a bit of rethink. If you can provide more information about the particulars of the situation then I could ponder it.

jamesladd commented 10 years ago

Lets say we have a re-usable component like a menu and we want this menu to be used on another view that has other uiActions. How should the menu view give its events to the containing view? For example, the menu might have entries like 'Cancel' and 'Done' and these in the context of another view mean different things.

On Wed, Jun 25, 2014 at 11:45 AM, Peter Michaux notifications@github.com wrote:

I cannot imagine a situation where you would want to do this. I think the design of the application needs a bit of rethink. If you can provide more information about the particulars of the situation then I could ponder it.

— Reply to this email directly or view it on GitHub https://github.com/petermichaux/maria/issues/79#issuecomment-47051933.

petermichaux commented 10 years ago

So you have one reusable view but you want it to do different things depending on the context? Use a different controller in each context.

jamesladd commented 10 years ago

I'll give that a go. It will work but I was hoping to avoid having to create multiple Controllers one for the view the menu is included on and one for the menu. We could re-use the one for the page but that might be confusing.

On Wed, Jun 25, 2014 at 12:17 PM, Peter Michaux notifications@github.com wrote:

So you have one reusable view but you want it to do different things depending on the context? Use a different controller in each context.

— Reply to this email directly or view it on GitHub https://github.com/petermichaux/maria/issues/79#issuecomment-47053636.

petermichaux commented 10 years ago

I really don't feel like I know enough to answer your question in the context that you have. What I wrote in my last comment above about using different controllers to have one view behave differently depending on context is very generic but true. That is what controllers are all about: the strategy pattern.

jamesladd commented 10 years ago

I think the answer is good as it reminds us of the need for a strategy and which piece of MVC implements that strategy. I'll look at our requirements with that reminder and see how we go.

On Wed, Jun 25, 2014 at 2:04 PM, Peter Michaux notifications@github.com wrote:

I really don't feel like I know enough to answer your question in the context that you have. What I wrote in my last comment above about using different controllers to have one view behave differently depending on context is very generic but true. That is what controllers are all about: the strategy pattern.

— Reply to this email directly or view it on GitHub https://github.com/petermichaux/maria/issues/79#issuecomment-47058504.