JavaScriptMVC is an open-source
rich Internet application
A rich web application (originally called a rich Internet application, or RIA or installable Internet application) is a web application that has many of the characteristics of desktop application software. The concept is closely related to a sin ...
framework based on
jQuery
jQuery is a JavaScript library designed to simplify HTML DOM tree traversal and manipulation, as well as event handling, CSS animation, and Ajax. It is free, open-source software using the permissive MIT License. As of Aug 2022, jQuery is ...
and
OpenAjax. It extends those libraries with a
model–view–controller
Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements. This is done to separate internal representations of infor ...
architecture and tools for testing and deployment. Because it does not depend on server components, it can be combined with any web-service interface and server-side language like
ASP.NET,
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
,
Perl
Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
,
PHP
PHP is a General-purpose programming language, general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementati ...
,
Python, or
Ruby
A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum (aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapp ...
.
History
The first release of JavaScriptMVC was published in May 2008. JavaScriptMVC 2.0 became stable in June 2009 and is based directly on jQuery, mainly to keep the code size small and to focus on its unique features. Version 3.0 was released in December 2010.
CanJS, JavaScriptMVC's extracted MVC parts, was released in April 2012. In May 2015, JavaScriptMVC was rebranded as DoneJS with an extended feature set and scope.
Controller
A controller is a list of functions that gets called back when the appropriate event happens. The name of the function provides a description of when the function should be called. By naming functions in the correct way, the Controller recognizes them as Actions and hooks them up correctly, for example:
$.Controller('TodosController',);
A controller can also handle
OpenAjax events, for example:
$.Controller('TodosController',);
View
JavaScriptMVC uses EJS templates to render HTML data in controllers and inject them into the
DOM. The syntax was inspired by
ERuby
Embedded Ruby (also shortened as ERB) is a templating system that embeds Ruby into a text document. It is often used to embed Ruby code in an HTML document, similar to ASP and JSP, and PHP and other server-side scripting languages. The templ ...
and is similar to PHP or other server-side template engines.
For example, file "test.ejs" ( data =
"Hello", "World" ):
<% for (var i=0, len = data.length; i < len; i++) %>
produces the following "output":
Model
JavaScriptMVC's model and it associated plugins provide lots of tools around organizing model data such as validations, associations, lists and more. But the core functionality is centered around service encapsulation, type conversion, and events.
The Model class provides basic functionality to organize the application's data layer.
$.Model('Todo', ,);
Tests
JavaScriptMVC also comes with a comprehensive test plug-in that supports classic unit tests for models, as well as functional tests, that are required to deal with event driven architectures. Tests can be run on the command line with Rhino, using Selenium and during development with the integrated test console pop-up window.
References
External links
*
JavaScript libraries
Ajax (programming)
{{compu-prog-stub