Blog

Jan 28

Patching Modern Dojo

By on January 28, 2015 2:41 pm

DojoFAQ

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.

As an example, Dojo 1.10 introduced dojo/throttle into the core—along with the extension event dojo/on/throttle—for ensuring that a function is fired only once during the specified interval. However, if you are developing with an earlier version of Dojo (for example, 1.9.6), you will either need to upgrade to 1.10.x or provide a patch to use it with 1.9.6. In this post, we will create patches for these modules.

Jan 22

The road to Intern 3

By on January 22, 2015 12:38 pm

Intern

We normally try to schedule new minor releases of Intern about once every four to six weeks, but when we are working on a major release, there will often be a larger than usual gap in the release cycle. In order to keep our users informed of what’s going on, we wanted to write about what we’ll be doing over the next six to twelve weeks for Intern 3, during which time there will be no new releases (except for possible critical patch releases).

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:

Jan 14

Dojo FAQ: Testable store-backed widget

By on January 14, 2015 1:11 pm

DojoFAQ

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.

define([
  'dojo/_base/declare',
  'dojo/dom-construct'
], function(declare, domConstruct) {
  return declare(null, {
    store: null,

    _setStoreAttr: function (store) {
      this._set('store', store);

      if (store) {
        this._renderItems(this.store.query({}));
      }
    },

    _renderItems: function (queryResults) {
      queryResults.forEach(function (item) {
        var renderedItem = this._renderItem(item);
        domConstruct.place(
          renderedItem,
          this.containerNode || this.domNode
        );
      }, this);
    },

    _renderItem: function (item) {
      // render the item and return its DOM node
    }
  });
});
Jan 8

Robust JavaScript Application Architecture

By on January 8, 2015 1:11 pm

In October, 2014, I was coerced invited to deliver a talk at the first FullStack conference in London, a conference focused on Node.js, JavaScript and hackable electronics. The conference was an interesting cross-section of all things related to JavaScript.

A topic that’s been on my mind lately is how to choose a robust architecture that’s right for your application. The point of the talk was to encourage people to challenge assumptions and not just choose whatever is popular or whatever they know best. I’m sure some attendees in the audience just wanted to be told which framework to use, but the point was to make people really challenge themselves, and find solutions that work now, but are flexible enough to change later.

The talk is now available online:

JavaScript architecture assistance

JavaScript Application architecture is something we specialize in at SitePen, as we see far too many organizations struggling in this area. If you need assistance, please contact us to talk more about your application and how we can help.

Dec 5

Intern 2.2 released

By on December 5, 2014 12:24 pm

Today we’re pleased to announce the release of Intern 2.2. Along with improvements to existing functionality and a few bug fixes, this release includes a new console-mode reporter that provides a more detailed view of the testing process and improved rendering of differences between objects. Full details are in the release notes; read on for some of the highlights!

Dec 1

Escape the Winter and Learn Dojo in Phoenix

By on December 1, 2014 12:29 pm

Good news everyone!

Now that summer is over, there’s no more heat to complain about! That just leaves, ah yes, the bitter cold. Sure, maybe you’ve been handling it well enough so far by staying busy with holiday planning, but what happens when the New Year comes? Suddenly nobody is “Dreaming of a white…” anything, anymore.

Your best hope is escape. And for that, we have a plan!

Winter Protection Program

Hello there, Brudolph

Pack your bags, leave it all behind and join us in the Phoenix area for sunshine, warm weather and, oh right, hands-on Dojo workshops.

Our expert approach and guided development by Dojo co-founder Dylan Schiemann, together with live code examples and tons of reference material go great with sunscreen and a cool beverage (Margarita, Señoras y Señors?).

Half the cost, twice the temperature

Register by December 31 with promo code HOLIDAY2014 and you’ll save 50%!

Nov 17

dgrid 0.4 released!

By on November 17, 2014 1:30 pm

Coinciding with the initial release of dstore, the next-generation Dojo data store, we would like to announce a new release of the best Dojo data grid: dgrid 0.4!

While this release does not focus on new features, it is an exciting release because we refactored some important components and improved dgrid’s stability while making it more flexible and extensible. Let’s take a look at the most significant changes.

A better store for tomorrow

dstoreDojo object store support in dgrid is an important and convenient way to populate a grid with your data. Connect a grid to an observable store and your grid will update automatically as modifications are made in the store.

Unfortunately in earlier versions of dgrid, there were edge cases that would cause a grid to get out of sync with an observable store. While dgrid 0.3.13 and later worked around many of these issues, ultimately this introduced a significant amount of code to deal with shortcomings of dojo/store/Observable. dstore 1.0 introduces a new Trackable mixin that is the evolution of Observable. dstore/Trackable allows dgrid to stay in sync with all store updates much more easily.

Because of improvements dstore provides over the Dojo object store API, dgrid 0.4 no longer supports the Dojo store API. Take a look at the Using Grids and Stores tutorial to see dgrid and dstore in action together.

Pulling the plug on plugins

Column plugins provided an extremely useful and expressive way to add functionality to a grid’s columns, but some people found them a bit confusing to use, and they tend to be very difficult to extend. We decided to convert the column plugins from decorator functions to declare mixins. Mixins are a familiar concept that are not only easy to use, but also easy to extend. Now you have the option to customize the column mixins as you do with any other dgrid component.

Inching towards the future

dgrid 0.4 is a few pounds lighter because we dropped support for IE 6, IE 7, quirks mode, and Dojo 1.7. dstore was designed for Dojo 1.8 and above, so dgrid 0.4 inherits this dependency. We’ve also removed old dgrid APIs which were already marked as deprecated during the 0.3 line.
intern2
Intern 2: dgrid has used the Intern as its testing stack for over a year. For 0.4, we’ve updated its tests to work with Intern 2, to continue to benefit from future fixes and enhancements.

Bower: dgrid 0.4 also includes a bower.json, as we’ve received numerous requests for better bower support. Now you can use bower to install dgrid along with its dependencies in one command.

Step into the Laboratory

One thing dgrid lacked was a sandbox providing a comprehensive demonstration of its features. We’ve put together the dgrid Laboratory to help fill that void. Take it for a spin, and feel free to have a look at the code, too – it’s included in the dgrid repository!

Migrate on over to dgrid 0.4

Unfortunately, this dgrid release is not plug-and-play for everyone due to the extent of the valuable updates that we made. If you are using a Dojo object store or one of the column plugins, you will need to make some changes to your code when you upgrade to dgrid 0.4.

The good news is the changes are pretty straightforward, and the even better news is we have written a dgrid 0.4 Migration Guide to help you out.

In addition to the Migration Guide, we have also updated the dgrid tutorials and demos.

For more details about the changes made in dgrid 0.4, please take a look at the dgrid 0.4 release notes. If you have questions or think you’ve found a bug, you can find links to the appropriate resources in the dgrid README.

Introducing dstore

By on November 17, 2014 1:24 pm

dstore 1.0

Dojo has long distinguished itself with a robust and complete application architecture. And the foundation of this architecture has been the store interface, providing clean separation and consistent interface between presentation and data sources. We are committed to continuing to improve this architecture, and in this pursuit, we now releasing dstore, a next generation object store interface and set of data modeling components.

dstore is an exciting new package that provides a number of significant improvements over the prior data store framework, including a more fluent querying API, improved event notification, advanced cross-store filtering, and a more modular mixin system that allows us to easily combine components with alternate format support, advanced querying support, and more. In this post, we want take a brief look at these new features and improvements. From there, you can explore the tutorials and documentation that we have written for this new package.

Oct 22

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

By on October 22, 2014 1:02 pm

DojoFAQ

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.