dojo

Dojo Select onChange event firing when changing value programatically

瘦欲@ 提交于 2019-11-29 06:22:45
I have a dojo (dijit) select dropdown that calls a js function onChange. I was expecting this to only call the onChange function when the user changes the value in the dropdown, however, it even calls the onChange function when I programatically change the value of the dropdown from js code. How do I get it to only call the function when the user changes the dropdown value? It shouldn't call the function when I programatically change the value. <select jsId="ddlBoundaryType" id="ddlBoundaryType" name="ddlBoundaryType" dojoType="dijit.form.Select"> <option value="0">Circle</option> <option

Dojo Builds…? What now?

谁说胖子不能爱 提交于 2019-11-29 04:40:24
A while back, I looked into a solution for the "flash of unstyled content" when using Dojo and Dojo themes. Someone suggested to combine everything by creating a build, and it'll reduce the load/parse time and remove the need to use preloader overlays, etc. However, it seems like Dojo is severely lacking in straightforward, "real world" useage examples and tutorials for a lot of its functionality, this especially. A lot of the resources tell you how to set up a build, but not how to implement it. Let's say I have this in "pageinit.js": require([ 'dojo/parser', 'dojo/dom', 'dojo/dom-class', /

Detect whether postMessage can send objects?

末鹿安然 提交于 2019-11-29 03:36:18
问题 I'm looking for a neat way to detect whether postMessage in the browser supports the sending and receiving of objects or just strings. I figure that someone out there must have wrote something that does this but I have not managed to find a solution. I'm using postMessage to send data to/from a WebWorker. Whilst detecting whether the browser supports workers is straight-forward, detecting whether objects can be send via postMessage has proved more difficult. I'd like to write a simple

How to retrieve XHR response code (+timestamp) of AMD'ized Dojo?

▼魔方 西西 提交于 2019-11-29 02:16:55
With the "old" Dojo one could pass a second argument ioargs to the load function of a Xhr request ( see Example 6 here ). This ioargs provided (among other things) the timestamp and status code of the request. But how can I achieve this with the new and "cleaner" (and forward compatible) Dojo? Unfortunately, I could not find any hints in the current documentation . The following should be a port of above referenced example to the "new" Dojo. But, ioargs will be undefined: require( "dojo/request/xhr", "dojo/dom", "dojo/domReady!", function(request, dom){ // Look up the node we'll stick the text

Dojo入门:DOM操作

风流意气都作罢 提交于 2019-11-29 01:45:01
作为一款功能齐全的js工具包,dojo提供了统一的DOM操作方法。 dojo.byId dojo.byId 函数使您可以通过 id 属性选择一个 DOM 节点。该函数是标准 document.getElementById 函数的一个别名,但是显然简短易书写。 dojo.query 虽然dojo.byId可以方便的根据id来获取一个DOM节点,但是根据id获取每一个元素几乎是不可能的,因为id是唯一标识。如果一次想获取几个元素,我们可以通过dojo.query方法。 dojo.query 函数接受一个字符串参数,使用一个 CSS3 选择器引用您想选择的元素。这种操作方式很像jquery对DOM的操作。如果我们想获取页面中的某一个class的所有元素,只需要使用以下代码: dojo.query(".class") 这个方法将返回一个NodeList,我们可以通过遍历这个list来操作每一个元素。 dojo.body dojo.body方法返回document的body元素 dojo.create dojo.create方法创建一个元素 dojo.destroy dojo.destroy方法会从父元素中删除该元素,并删掉该元素的所有子元素 dojo.empty dojo.empty方法将删除掉所有子元素 dojo.forEach dojo

Dojo入门:增强的Ajax功能

喜你入骨 提交于 2019-11-29 01:44:55
随着Web技术的发展,RIA似乎已经成了主流,Ajax也随之成了不可或缺的部分。Ajax是异步的javascript和Xml,虽然现在很多交互的数据格式都不再严格的采用XML,但这种异步的操作却越来越流行了。目前主流的JS工具包都包含了Ajax的功能,dojo也有自己的Ajax框架XHR。 XHR框架 XHR框架是dojo对ajax支持的一组方法,允许想服务器端发出get、post、put、delete请求,这些方法包括: xhrGet xhrPost xhrPut xhrDelete 所有这些函数都遵守相同的语法:接受一个属性配置对象作为参数。在这些对象中您可以定义您想要发出的 Ajax 请求的各个方面。再一次说明,这些选项在所有 XHR 函数中都是一样的。 比较常用的选项: url:这是 HTTP 请求的 URL。它必须和发出这一请求的页面有同样的域和端口组合。 handleAs:允许您定义响应的处理格式,默认是 text,但是,json、javascript、xml、还有一些其他选项也可用。在本节后面您将看到一个创建 Ajax 请求的示例,使用一个处理 JSON 响应格式的回调函数。 form:<form> 元素的一个引用或者字符串 ID 表示。form 中每个字段的值将被同请求一起作为请求体发送。 content:一个对象,包含您想要传递给请求体中资源的参数。如果两者都提供

Dojo入门:dojo中的事件处理

安稳与你 提交于 2019-11-29 01:44:48
JS为DOM添加事件 在原生的环境下,为DOM添加事件处理函数有多种方法: <input type="button" name="btn" value="点击…" id="btn" onclick="btnClick" /> 或者使用以下方法: <input type="button" name="btn" value="点击…" id="btn" /> <script type="text/javascript"> function btnClick() { alert("我被点击了"); } document.getElementById("btn").onclick = btnClick;</script> 以上这两种方法存在明显的弊端:每一个事件只能指定一个事件处理函数,另外,如果要移除一个事件处理函数,似乎只能使用: document.getElementById("btn").onclick = null; 或者 document.getElementById("btn").onclick = ""; 这种方式极不利于模块化编程。W3C DOM Level2 标准有了新的事件模型,新的事件模型允许为事件添加多个处理方法,并加入了事件冒泡机制。 使用新的事件模型来添加事件处理方法: <input type="button" name="btn" value="点击…"

Dojo入门:初识Dojo

有些话、适合烂在心里 提交于 2019-11-29 01:44:30
Dojo的全称是Dojo Toolkit,始创于2004年,是当前各种蓬勃发展的JS工具包中的佼佼者。Dojo 为富互联网应用程序(RIA) 的开发提供了完整的端到端的解决方案,包括核心的 JavaScript 库,简单易用的小部件(Widget)系统和一个测试框架,此外,Dojo 的开源开发社区还在不停地为它提供新的功能。 Dojo特性 Dojo Toolkit 的特性可以分到 4 个不同部分。这种划分使得开发人员可以将库大小保持到最小,确保应用程序性能不受大量 JavaScript 库下载的影响。例如,如果您只需要 Ajax 支持性能,您只需要包含 base 包;不需要包含扩展的 Dijit UI 组件,在本系列中稍后您将学习更多关于 Dojo 加载不同模块的方法。 Base Base 包提供 Dojo Toolkit 的基础,包括一些功能,比如 DOM 使用函数、CSS3 基于选择器的 DOM 查询、事件处理、基本的动画、以及 Dojo 基于类的面向对象特性。本文主要介绍 Base。 Core Core 包包含一些 Base 中没有包含的附加特性。通常,这些特性不像 Base 中的特性那样频繁使用;因此,它们单独加载减轻 Base 包的负担。从这一点上来讲,Core 包提供一些实际有用的组件,包括高级动画拖放、I/O、数据管理、国际化(i18n)、浏览器历史管理。Core

Is there a data structure like the Java Set in JavaScript? [duplicate]

霸气de小男生 提交于 2019-11-29 01:30:32
This question already has an answer here: Does JavaScript have an implementation of a set data structure? 6 answers I want to use a data structure in JavaScript that can be used to store number of IDs. I should be able to check if a key already exists in that set, something like Java Sets. I want to achive same behaviours as follows (this code is in Java): Set<String> st = new HashSet<String>(); //add elemets if(st.contains("aks") ){ //do something } I want a JavaScript/dojo equivalent of the above code. I've written a JavaScript HashSet implementation that does what you want and allows any

How to refresh datagrid

大城市里の小女人 提交于 2019-11-28 20:38:35
问题 I create dojox.grid.datagrid and I fill content from array like on example last example on page. During time, I change value of that array in code. How to refresh content of that grid ? How to load new data from changed array ? 回答1: To change values in the grid, you will need to change the value in the grid's store. The grid data is bound to the store data, and the grid will update itself as needed. So the key is to understand Dojo's data api and how stores work in Dojo. Rather than