Activate your free membership today | Log-in

Monday, August 7th, 2006

JavaScript Model-View-Controller with Dojo toolkit

Category: Dojo, Framework, Programming

<p> In this new post on his blog, Alexander Netkachev demonstrates how to create a Model/View/Controller framework in Javascript with when help of the Dojo Toolkit.

My goal for this article is to write a simple JavaScript component that can show a power of the language. The component is a kind of the HTML ListBox (“select” HTML tag) control with an editable list of items: the user can select item and remove it or add new items into the list. I will use Dojo toolkit class building functions [link] to create three classes that implement the Dojo’s event system for subscribing on DHTML events and for notifying the View about changes in the Model.

He first talks about what the Model/View/Controller pattern is for those that haven’t used it before (a simple definition). He applies it more to web applications t make it easier to bridge the gap between traditional web development and this design method.

From there it’s all about thge code, first the creation of the ‘ListModel’ to handle the functionality, then the ‘ListView’ to make the HTML output of the script, and, finally, the ‘ListController’ to manage the view and model when a request comes in. Code for that is included too, making a simple multi-select box you can easily add and remove items from.

Related Content:

  • Sun gets serious about Ajax
    Sun Microsystems Inc. demonstrates a commitment to Ajax with its new involvement with to alliances working on Ajax technology, the OpenAJAX Alliance...
  • Ajax framework released
    Simplified Ajax development is the goal of a new framework from Emergetk, released under the General Public License (GPL). It is written in C# and the...
  • Choosing an Ajax framework
    Your customers won't have to fear Ajax if they have the right tools to work with. Help them determine which Ajax-specific framework, library or...
  • Ajax everywhere: Which framework to choose?
    Writing and debugging Ajax, a JavaScript- and XML-driven development technique, can be difficult. In this tip, an expert introduces several frameworks...
  • Ajax everywhere: Which framework to choose?
    Writing and debugging Ajax, a JavaScript- and XML-driven development technique, can be difficult. In this tip, an expert introduces several frameworks...

Posted by Chris Cornutt at 8:23 am
Comment here

++++-
4.3 rating from 26 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.