dojo

初看jQuery,比较dojo与jQuery的不同点

半世苍凉 提交于 2019-12-22 17:19:50
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 以下观点是建立在我初看jQuery,但并没有对jQuery详细理解的情况下。 可能随着后面对jQuery的使用,而增加更深的了解。也可能发现我当初的观点是错误的。 大体浏览了一下jQuery的文档,发现jQuery与dojo存在以下相同的地方: 1,dojo与jQuery都提供了对HTML DOM的快捷操作方法。 2,都提供了css的操作方法。 3,提供了DOM node的query方法。 4,包装了xhr。 5,提供了事件注册机制。 6,提供了简单的动画效果。 不同的地方在于: 1,dojo提供了面向对象的js开发机制。是一个js的framework。jQuery提供了基于client side js的工具箱。在dojo中,用户可以根据dojo的模板定义自己的类。 2,dojo提供了dijit,以及如何定义自己的dijit的方法。dijit是dojo中可以重用的控件。它自身带有html template。dijit像一个模板,由模板生成的实例可以把html template生成的dom以及dom上的事件方法都当作实例内部方法来用。dijit可以放到document的任意节点上。 3,dojox提供了更多的扩展包,比如grid。 4,dojo提供了国际化和本地化方法。使用dojo.i18n. 5

Dojo 国际化进阶

那年仲夏 提交于 2019-12-22 17:05:35
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Dojo 官网: https://dojo.io 使用消息包 Dojo 的消息包概念是一个 Map 对象,其中存储用 key 标识的文本消息,每个 key 标识的消息内容可以用一到多种语言表示。 当需要向最终用户显示消息时,Dojo 应用程序使用 key 来引用该消息。这就避免了在代码中硬编码某一种语言的文本,而是提供了一门或多门语言的外部消息集,这些消息集能独立于应用程序的代码单独维护。 在渲染时,根据部件中引用消息 key 时的当前区域设置,Dojo 的 i18n 框架使用指定语言的文本内容替换掉消息 key。 Dojo 应用程序可以选择在整个应用程序中只使用一个消息包;也可以将消息进一步拆分的更细,接近于一个部件对应一个消息包,最终得到一个包含多个消息包的应用程序。 包的默认语言 每个消息包中都会包含多门语言的翻译。其中一门语言需要作为其余语言包的默认模块。这个默认的语言模块用于导入(或引用)包,主要实现两个需求: 提供一组完整的消息 key 及对应的内容(使用默认语言),如果包中的其他语言没有覆写某一个 key,则回退使用这些 key 和内容 列出包中支持的其他语言,以及每一个支持的语言模块消息集的加载机制 TypeScript 结构 包中的每一种语言都是一个 TypeScript 模块

How can I filter a dstore using the contains method?

邮差的信 提交于 2019-12-22 13:48:11
问题 I have a dgrid populated with a dstore plain old Memory collection, that I am trying to filter using the 'contains' filter method. The store data looks something like this: [ {id:"25", users: ["13", "15"]}, {id:"347", users: ["13"]}, {id:"653", "users":["13", "17"]} ] I want to retrieve all the records where a given user is in the users array. From my understanding, I was expecting to be able to set up a filter like new Filter().contains('users', '15'); and set that as the collection for the

Add a row in Dojo datagrid

假装没事ソ 提交于 2019-12-22 08:59:36
问题 Struggling to find a bit of code to easily understand. How do you add a row and clear all rows in a Dojo datagrid (version 1.4.2). Lets say the data is 2 columns with customerID and address. I am using dojo.data.ItemFileWriteStore to store values in - but again not quite sure how this should be used. It can't be that hard. Cheers. 回答1: You can get the data store reference from the grid using grid.store , then you can use store.newItem() to create a new item in the store. This new item is

dijit filteringSelect with min length

随声附和 提交于 2019-12-22 08:18:43
问题 I can't seem to find a way to require the filtering select input to be of a certain length. I've tried like this: new dijit.form.FilteringSelect({ 'name': 'bla', 'store': jsonRestStore, 'searchAttr': "name", 'pattern': '.{3,}', 'regExp': '.{3,}' }); but it doesn't change a thing. I want the filtering select to only query the store, if at least 3 characters have been entered. Can't be that exotic a requirement, can it? There are thousands of items behind that store, so querying that with just

Explain this confusing dojo tutorial syntax for declare

我们两清 提交于 2019-12-22 06:32:36
问题 I am reading the syntax for using dojo's declare for class creation. The description is confusing: The declare function is defined in the dojo/_base/declare module. declare accepts three arguments: className, superClass, and properties. ClassName The className argument represents the name of the class, including the namespace, to be created. Named classes are placed within the global scope. The className can also represent the inheritance chain via the namespace. Named Class // Create a new

How to load a JS file that is not a module in dojo?

痴心易碎 提交于 2019-12-22 06:09:11
问题 I'll start by saying that I am a javascript and dojo noob. However, I have been working on writing some unit tests for my js code, using the D.O.H framework. One thing I noticed is that the framework does not seem to have a way to mock XHR requests. So I decided to use sinon for the mocking. Heres my question, I cannot successfully load the sinon code into my dojo module. Here is what I tried: define(["doh/runner", "tests/sinon-1.4.2"], function(doh, sinnon) { ... }); I have the tests package

How to add a div dynamically by using Dojo?

荒凉一梦 提交于 2019-12-22 05:57:39
问题 I have a the following static div: <body> <div id="div1"></div> .... I want to add a div with id "div1_1" within div1 dynamically by using dojo. How can I do it? 回答1: You can do it using just Dojo Base — no need to include anything, if you use the trunk or Dojo 1.3: dojo.create("div", {id: "div1_1"}, "div1"); This line creates a div with id "div1_1" and appends it to the element with id "div1". Obviously you can add more attributes and styles in one go — read all about it in the documentation

How can you iterate over an object (associative array) in Dojo?

江枫思渺然 提交于 2019-12-22 05:33:19
问题 Does Dojo have a method similar to jQuery's each() that allows you to pass an object to iterate over? jQuery.each() allows you to pass either an array or an object. In the latter case, the callback function receives both a key and the value. Is there something that allows you to do this in Dojo? 回答1: Looks like you are looking for dojox.lang.functional.object.forIn . There's no actual documentation page in dojo reference, only a small example in article Functional fun in JavaScript with Dojo:

Dojo “loading”-message

倾然丶 夕夏残阳落幕 提交于 2019-12-22 05:19:24
问题 I'm new to Dojo, so I need a little help. Some of my links takes a while (when the user clicks, it takes several seconds before the page starts loading), and I'd like to add a "loading"-message. I can do it the "old fashion way", but I want to learn the new, easier, smarter Dojo-way. Exactly how it works is not important right now, but I imagine something like this: A rectangle appears in the middle of the browser-windows. (Not the middle of the document.) It has an animated gif, and a