请输入您要查询的百科知识:

 

词条 JavaScriptMVC
释义

  1. History

  2. Controller

  3. View

  4. Model

  5. Tests

  6. References

  7. External links

{{Infobox software
| name = JavaScriptMVC
| logo = Javascriptmvc.png
| logo size = 192px
| developer = Justin B. Meyer, Brian Moschel
| released = {{Start date and age|2008|05}}
| discontinued =
| latest release version = 3.3
| latest release date = {{Start date and age|2013|07|23}}
| latest preview version =
| latest preview date =
| status = Now marketed as DoneJS[1]
| programming language = JavaScript
| operating system = Cross-platform
| license = MIT License[2]
| website = {{Official URL}}
}}{{Portal|Free and open-source software}}

JavaScriptMVC is an open-source rich Internet application framework based on jQuery and OpenAjax. It extends those libraries with a model–view–controller 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, Perl, PHP, Python, or Ruby.

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',{   ".todo mouseover": function(el, ev){     el.css("backgroundColor","red")   },   ".todo mouseout": function(el, ev){     el.css("backgroundColor","")   },   "#create_todo click" : function(){     this.find("ol").append("New Todo");   } });

A controller can also handle OpenAjax events, for example:

 $.Controller('TodosController',{   "main.test subscribe": function(ev, publisherData){     // TODO: do something   },   "other.event subscribe": function(ev, publisherData){     // TODO: do something   } });

View

JavaScriptMVC uses EJS templates to render HTML data in controllers and inject them into the DOM. The syntax was inspired by ERuby 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++ ) { %>
  • <%= data[i] %>
  • <% } %>

produces the following "output":

  • Hello
  • World

Model

The Model class provides basic functionality to organize the application's data layer.

 $.Model('Todo',{  findAll: '/todos',  findOne: '/todos/{id}',  create: '/todos',  update: '/todos/{id}',  destroy : '/todos/{id}' },{});

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

1. ^{{cite web|url=http://donejs.com/About.html#section=section_Evolve|title=DoneJS is the successor to JavaScriptMVC.|publisher=Bitovi}}
2. ^{{cite web|url=https://github.com/bitovi/javascriptmvc/blob/master/license.md|title=JavaScriptMVC license|publisher=Bitovi|accessdate=12 December 2012}}

External links

  • {{Official website}}
  • [https://github.com/bitovi/javascriptmvc GitHub Repo]
  • Old Project page on Google Code
{{web-software-stub}}{{compu-prog-stub}}

2 : JavaScript libraries|Ajax (programming)

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/17 9:06:46