views:

6540

answers:

13

Are there any client-side Javascript MVC (micro-)frameworks?

I have a rather complicated HTML form and it would benefit from the MVC pattern.

EDIT:

I imagine a good solution would provide the following:

  • Model and View update the Controller when values change (Observer pattern)
  • Populate the model from the form data when the page loads
  • Populate the form from the model when the model changes

Ajax, comet, jsonp and all that jazz are serious overkill. I edited this post to say say micro-framework.

+6  A: 

Indeed there is: http://www.javascriptmvc.com/

I think you will find this sufficient!

Filip Ekberg
That site has a blink tag. o_0
Terry Donaghe
that site doesn't load for me at all
Josh
Try again, should work again.
Filip Ekberg
+1  A: 

I wouldn't call this a micro-framework, but it sure looks interesting: Cappuccino Web Framework

PEZ
A: 

Trimpath

I.devries
A: 

There was a key-value binding JavaScript framework called "Coherent", which was inspired by Apple's Cocoa Bindings. The framework has been bought by Apple, but there is still an old copy at http://github.com/trek/coherentjs/tree/master.

Steve

Steve Harrison
+2  A: 

Like other responses, it's probably overkill for what you need, but SproutCore is an MVC framework and it doesn't look any more heavyweight than JavascriptMVC or TrimPath's Junction.

Unfortunately, none of these seem to be built on the principle of progressive enhancement.

system PAUSE
+1  A: 

The popular ActionScript MVC framework PureMVC was recently ported to JavaScript. I haven't had a chance to try it out yet but I am confident its good.

http://trac.puremvc.org/PureMVC_JS/

Ricky
I like it for flex. Simple and powerful.
Glenn
+1  A: 

If your requirements are really simple, you could write your own simple MVC like Alex Netkachov did.

His examples are built on dojo (Note: they don't work for me on his page because of a missing dojo.js file), but you could follow the pattern in plain Javascript.

system PAUSE
+1  A: 

Jamal is the lightweightest I've seen. It's also based on jQuery (bonus). Have not used.

http://jamal-mvc.com/

KevBurnsJr
+4  A: 

JavaScriptMVC is an excellent solution. It's everything is a plugin approach enables you to select only the features you need. As of 2.0, it's based on jQuery.

On progressively enhancing your website, that's left up to the user as JMVC provides just a middle layer for development - it's up to you to make that design choice yourself.

However, JavaScriptMVC is simply the best general purpose JavaScriptMVC library because of its powerful event delegation based controllers.

Event delegation lets you escape having to attach event handlers, and simply create rules for your page.

Finally, JMVC is much more than a MVC architecture. It has all parts of the development cycle covered with:

Code Generators Selenium and Env.js integrated testing Documentation Engine Automatic Concat+Compress Error detection and reporting

Justin Meyer
+1  A: 

Please also checkout jquery-claypool.

jquery-claypool is a small, fast, railable mvc framework built on jquery, based on my experience with django, rails, spring etc. Its very light weight and runs on both on the client and in server environments.

it provides a routing framework for clean mvc, category logging, filters (aop), lazy creation of controllers, inversion of control, convention-over-configuration and not much more by design.

it doesn't do anything jquery already does, feels like jquery, and works like a good framework should: simply.

jquery-claypool

Hope you check it out.

Thatcher

Chris Thatcher
A: 

Cheers, Thatcher, I just had a look at jquery-claypool and it spoke to me straight away, looks nice, gonna use it.

Lindsay Kay
-1: not an answer to the OP's question.
Roy Tinker
Hey Lindsay, this is not a chat. :)
bzlm
A: 

If you want to keep things under control and quite simple, you may don't need a framework, but just implement your own mvc pattern. Just check this article: Model-View-Controller (MVC) with JavaScript by Alex Netkachov on 2006.

Batailley
A: 

CorMVC, easy to understand and to start with, jquery based and does not depend on any server technology

epitka