views:

48

answers:

2

I'm thinking about an implementation of MVP - Passive View pattern in JavaScript. In most case the view will be simple dom elements where the presenter attaching event listeners. But when it comes to widgets like JavaScript based pseudo selectboxes, auto suggest or aria features, should this be part of a JavaScript view class or should the logic to change the view be part of the presenter? I've looked at the javascriptMVCs view and it seems that they are only template generated html without any logic. But for me there seems no different between a presenter who's listenen to html selectbox and one who listenen to an pseudo selectbox with javascript logic to mimic a real select box. Both shouldn't care about how the box is working internally, they just have to listen the change event.

So what to you think. Whats the job of view class.

+1  A: 

The View object should be responsible for drawing itself. A Passive View knows how to do stuff, not what to do. It must be responsible for firing its own events. Just because it is a custom select box widget does not make it any different than a regular select box.

If the presenter took over all the views responsibilities, then there is no need for a view at all. Might as well just have a presenter only.

Anurag
Did drawing itself, including change styles or attributes on user interaction or is this part of the presenter?
eskimoblood
+1  A: 

JavaScriptMVC's views are dummy client side templates. It's node controllers tend to take on a more traditional View role.

Justin Meyer