Blog

Mar 6

Understanding Deferreds and Promises in Dojo

By on March 6, 2015 11:18 am

It’s been a while since we’ve dove into Dojo’s Deferred module on the SitePen blog—the last time was back in 2010 when we introduced the promise-inspired improvements that landed with Dojo 1.5. Quite a lot has happened since on the topic, including a ground-up rewrite of Dojo’s asynchronous foundations in 1.8+, so it’s about time we take another look at deferreds and promises and how it all fits together in Dojo.

Jan 21

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

By on January 21, 2015 10:10 am

DojoFAQ

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:

  1. User opens web site
  2. Web site presents authentication screen
  3. User enters credentials
  4. 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 authentication is required? A common approach is to use redirects to an authentication page:

Jul 30

Dojo FAQ: Why do I need to use an HTTP server with Dojo?

By on July 30, 2014 11:52 am

DojoFAQ

When developing for the web, it is a recommended best practice to always test your application during development with a web server. This is for two primary reasons. By running a web server, you can approximate a production environment similar to how your application will be served to your users. Also, browsers implement a same-origin policy that is different for quasi-protocols like file://. Many of Dojo’s modules like dojo/i18n, dojo/text, Dijit templates, and dojox/gfx depend on loading files from the same origin.

Jul 16

Dojo FAQ: When should I provide callbacks to dojo/when?

By on July 16, 2014 12:04 pm

DojoFAQ

In JavaScript it is common to use a Promise as a placeholder for a value which will eventually be provided upon completion of some operation. However most JavaScript methods run synchronously and immediately return a value. Dojo’s when module provides a transparent way to apply callbacks to either values or promises. It can do this in one of two ways:

  • Using when(value) to always create a promise
  • Passing callbacks to be applied directly to the value
Jul 9

FAQ: How can I create a JSONP service-based store?

By on July 9, 2014 11:16 am

DojoFAQ

Dojo’s store API is a common interface for providing data to user interface widgets, such as dgrid, Dijit Select, and Dojo Charting. The beauty of having a consistent API is that once you’ve defined an interface for a data source, that data becomes easily available to all widgets that support the store API. We’re going to look at how you can create a basic, read-only dojo/store API-compliant module for accessing GitHub’s API (specifically, GitHub issues), an example of implementing your own Dojo store.

Sep 21

Exploring dojo/json

By on September 21, 2012 4:52 pm

Dojo has long had great support for JSON through dojo.fromJson() and dojo.toJson(). But with the advent of ECMAScript 5′s JSON object, and the increased adoption of this API among browsers, there is now a standard API for JSON parsing and serialization. Dojo 1.7 added a module that aligns with this standard API. This enables Dojo to directly pass through parsing and serialization when native support exists. Using the native JSON parser and serialization is much faster, and allows Dojo to leverage the high-speed, in language capabilities. Also, Dojo’s dojo/json module is based on the feature detection (has() API) system that is integrated with the build system, so it will be possible to leverage the build system to create browser-specific builds (like mobile builds) where this module consumes just a few bytes.

Aug 21

Introducing dojo/request

By on August 21, 2012 6:00 am

As Dojo moves toward its 2.0 release, our focus has been on giving developers tools that will help them be productive in any JavaScript environment. This means creating consistent APIs across all environments. One area that has been sorely lacking, in this regard, is Dojo’s IO functions. We’ve always provided developers with a way to make requests in the browser (dojo.xhr*, dojo.io.iframe, dojo.io.script), but the API has been less consistent than some of us would like (dojo.xhrGet, dojo.io.script.get, etc.). Additionally, we’ve never provided a server-side implementation, and if we had, it would have been another module name and API call to remember.

With the release of Dojo 1.8, we have introduced the dojo/request API which provides consistent API calls between browsers, request methods, and environments:

require(["dojo/request"], function(request){
    var promise = request(url, options);
    promise.then(
        function(data){
        },
        function(error){
        }
    );
    promise.response.then(
        function(response){
        },
        function(error){
        }
    );
    request.get(url, options).then(...);
    request.post(url, options).then(...);
    request.put(url, options).then(...);
    request.del(url, options).then(...);
});
Jul 19

Now Supporting all Major Toolkits!

By on July 19, 2012 8:20 am

We have been providing JavaScript and Dojo support to freelancers, start-ups and Fortune 500 companies for nearly a decade. As we intently watch enterprise organizations everywhere begin to roll out AMD (read about why AMD matters) and the associated code improvements, we are thrilled with the industry’s direction toward toolkit interoperability! Why? Because! Our masterful engineering team, consisting of influential members of various open source communities, positions SitePen perfectly to offer full-on, front-end web development support to the world!

Getting right to the point, (The Official Point!), we are pleased to announce the expansion of SitePen Support to officially include more than fifteen popular open-source JavaScript toolkits!

Now supporting the following JavaScript toolkits:

  • Dojo
  • Persevere packages
  • dgrid
  • Curl.js
  • CometD
  • Twine
  • jQuery
  • Backbone
  • underscore
  • RequireJS
  • PhoneGap/Cordova
  • MooTools
  • jQueryUI
  • Wire
  • Socket.IO
  • Express

In addition to toolkits, we will continue to support your custom JavaScript source code, as well as key underlying technologies and formats, including JSON, HTML5, WebSockets, SVG/Canvas, Mobile Web, Server-Side JavaScript, AMD, Node.js and many more.

Our expertise with Dojo and advanced JavaScript is relevant for a wide-range of desktop and mobile web application projects and our approach to SitePen Support has always been flexible with the priority being to improve our customers’ web apps. We strive to support our customers in every way possible and we continue to be Dojo experts. In addition, we’re now committed to providing your organization with the front-end development expertise that will optimize your application regardless of which toolkits and technologies your company is comfortable using. You have our word!

Learn More About SitePen Support or Contact Us to get started today!

Apr 12

Dojo Tutorial: Layout with Dijit

By on April 12, 2011 12:01 pm
This entry is part 4 of 13 in the series Dojo Tutorials


Next in our ongoing series of Dojo Tutorials, we’ll tell you about Layout with Dijit.

Bring your layouts to life

Creating dynamic and interactive layouts is a challenge common to any graphical user interface. We have a lot of ability to create layout with HTML and CSS. Where CSS leaves off, Dojo picks up with a set of extensible widgets as a part of Dijit – Dojo’s UI framework. In this tutorial, we’ll explain how Dijit addresses common layout needs and see how easy it can be to create even complex layouts with just a few flexible widgets.

Check it out!

Sound interesting? Check out the tutorial.

Want to see a specific Tutorial? Want to Learn More?

Is there something you’d like to learn how to do with Dojo? Always wanted to know how something in Dojo works? Leave us a message in the blog comments and we’ll see about getting a tutorial created for you. Or sign-up for an upcoming SitePen Dojo Workshop to get a fully immersive hands-on experience with Dojo.