计算机程序虚拟的人生
虚拟世界中的游魂
 Dojo介绍
       Dojo 是一个用javascript语言实现的开源DHTML工具包。它是在几个项目捐助基础上建立起来的(nWidgets, Burstlib, f(m)), 这也是为什么叫它a \"unified\" toolkit的原因。Dojo的目标是解决开发DHTML应用程序遇到的那些,长期存在 、历史问题。historical problems with DHTML 跨浏览器问题。Dojo让你更容易 使web页面具有动态能力,或在任何稳健的支持javascript语言的环境中发挥作用。

a、利用dojo提供的组件,你可以提升你的web应用程序可用性、交互能力以及功能上的提高;
b、你也可以 更容易的建立degradeable user interfaces ??,dojo提供小巧的 widgets ,animate transitions;
c、利用它的低级APIs和可兼容的代码,写出轻便的、单一风格(复杂)的javascript代码,Dojo的 event system, I/O APIs, and generic language enhancement form the basis of a powerful programming environment.
d、通过Dojo提供的工具,你可以为你的代码写命令行式的单元测试代码。
e、the Dojo package system使你自己的代码更容易维护,偶合性更低。

Dojo通过很少的代码完成了以上的功能。(以后可能我详细说说dojo的package system ,只需要三个js文件)。当你写脚本时,只需要包含很少的js文件(大小)。也可以选择的(包含)下载dojo提供的庞大的功能。Dojo provides MultiplePointsOfEntry, InterpreterIndependence, ForwardLookingAPIs, and focuses on ReducingBarriersToAdoption.
  dojo试图建立一种新的标签语言DojoML。目标是,在DojoML和javascript脚本语言不变的情况下,用不同的render方式展示数据, Renderings may be made available in several rendering contexts (such as SVG, or perhaps even the desktop or Flash)。(比较美好啊)更进一步,the DojoML 剖析器可以接受html和svg为输入,容易的建立DegradeableResponsiveApplications。

第一部分  安装
第一个小节  怎么安装Dojo Toolkit
 Dojo在磁盘上只是一堆文件,它不需要特殊的设置,它可以通过以下三种途径获得:
 1、可以从google的内容分布网络获得
   加载的方法可以参考http://code.google.com/intl/zh-CN/apis/ajaxlibs/documentation/index.html#dojo
 2、.在你自己的服务器上使用Dojo
  a、下载最新的dojo包,地址:http://dojotoolkit.org/downloads;目前最新的包为1.3.1
  b、解压下载的压缩文件
         --dojo-release-1.3.1-src
            ----dijit
            ----dojo
            ----dojox
            ----util
  c、可以通过D:\Apache-Source\dojo\1.3.1\dojo-release-1.3.1-src\dojo-release-1.3.1-src\dijit\themes\themeTester.html 这样的路径来查看相关的JS例子
3、每日构建代码
   你可以通过SVN地址获得
For instance, Dojo Core repository is:
http://svn.dojotoolkit.org/src/dojo/trunk

There are two versions of this view: anonymous and committer.

For users (readonly):
http://svn.dojotoolkit.org/src/view/anon/all/trunk

For committers (read/write):
https://svn.dojotoolkit.org/src/view/committer/all/trunk

第二部分 Ajax
第一个小节 ajax
a、ajax and Dojo
1)XHR选项
例子:

// post some data, ignore the response:
dojo.xhrPost({
form: "someFormId", // read the url: from the action="" of the <form>
timeout: 3000, // give up after 3 seconds
content: { part:"one", another:"part" } // creates ?part=one&another=part with GET, Sent as POST data when using xhrPost
});
// get some data, convert to JSON
dojo.xhrGet({
url:"data.json",
handleAs:"json",
load: function(data){
for(var i in data){
console.log("key", i, "value", data[i]);
}
}
});

2)XHR回调
有三种方法可以附加到XHR选择对象,以确定当数据回调时该怎么做。


posted on 2009-06-29 14:20 小兄弟(Robbins) 阅读(357) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: