Category: FAQ

Dojo FAQ: How do I optimize a Dojo app for mobile?

Web applications can be deployed to many environments, including desktops, tablets, and mobile devices. We can even deploy web applications natively using a wrapper such as Apache Cordova to gain access to device features such as GPS, battery, and accelerometer data. However, it is not always optimal to package our application into a universal layer file, as we may be sending Cordova-specific code to our web users and packaging web-specific code with our native application. Luckily, Dojo provides us with

Read More »

Dojo FAQ: Is there a modern theme for Dojo?

One of the additions of the recent Dojo 1.11 release is a modern flat theme created with the Stylus preprocessor. The flat theme allows you to apply a modern, flat look and feel to existing Dojo applications.

Read More »

JavaScript in the Enterprise: Where do your developers turn for JavaScript Support?

The Situation Deadlines are looming and it looks like it’s is going to come down to the wire. A developer has hit a roadblock while trying to integrate code from another team and connect it to a third-party API. He can’t figure out where things are going wrong. Is it his code? Is it the other team’s code? Is it the API? A few hours in and he’s going in circles — with no answer in sight. ‘Who can I

Read More »

Dojo FAQ: How can I sequence asynchronous operations?

Dojo’s Deferred module provides a convenient way of managing asynchronous operations. If you’re new to deferreds, you can get a good introduction by reading our blog post and some tutorials on dojotoolkit.org: Getting started with Deferreds and Dojo Deferreds and Promises. There are a few features of the then method on a promise that are important to understand and remember: then always returns a promise the promise returned by then resolves to: the value returned by the callback passed to

Read More »

Dojo FAQ: How do I upload a CSV file, then access that data in my application?

While a more recent advancement allows us use the HTML5 file API to retrieve contents from files, this approach is not universally supported in web browsers as yet. Instead, we will access data from user-uploaded CSV files using the following steps: Upload a file to the server Retrieve the file from the server Load the data into an easy-to-use format

Read More »

Patching Modern Dojo

While it will not happen often, there may be times when you need to patch your Dojo source. Perhaps you discovered a bug and are waiting for the fix to be committed or released, or your application uses an older version of Dojo but you want to use features found in newer releases. Dojo’s AMD plugin loader makes it possible to apply patches without resorting to modifying the source files themselves, making it easier to upgrade your version of Dojo.

Read More »

Dojo FAQ: How can I handle recoverable server errors transparently with dojo/request?

A common scenario with web applications is accessing protected resources, which require authentication with the server in order to proceed. A common flow is as follows: User opens web site Web site presents authentication screen User enters credentials Web site presents protected information Authentication workflows This is simple enough to begin with, but what happens when the session times out? Or perhaps the application does not require authentication initially, but once the user initiates an action to access protected resources

Read More »

Dojo FAQ: Testable store-backed widget

As object stores are frequently used in Dojo-based applications, developers often ask about a good way to utilize stores in their custom widgets. Here we present a common pattern for doing just that in a two-stage approach, starting simple. A store-based widget needs two things at minimum: a way to set the store and a way to render items from the store. We start with a mixin that provides those elements. Note that standard documentation is omitted for brevity.

Read More »

Dojo FAQ: How do I load multiple versions of Dojo on the same page using modern Dojo?

The way modules are loaded changed with the introduction of modern Dojo (1.7+). Dojo now uses the AMD format for packaging and loading modules within an application. AMD avoids the use of globals, which limits the likelihood of unintended interactions between modules. By leveraging AMD and the flexible configuration provided by the Dojo loader, we can load different versions of the same package on a page without dangerous interactions.

Read More »

Dojo FAQ: How to use JSFiddle to provide a functioning test case

Making a case When collaborating with other developers nothing is better for conveying an issue than real, working code. To this end, JSFiddle provides a way to quickly create and share functioning test cases written in HTML, CSS, and JavaScript. It provides a customizable environment with support for Dojo and many other common frameworks, services for mocking Ajax requests, basic change control, and collaboration tools. The interface is simple and gets out of your way allowing you to quickly write

Read More »