define(['dojo/_base/connect','dojo/_base/xhr','dojo/_base/Deferred','dojo/hash'],function(connect,xhr,Deferred,hash){ return new (function() { var self = this; var current = ""; function init() { connect.subscribe('/dojo/hashchange', function(){ var url = hash(); self.goTo(url); }); } self.initial = function(location) { if ( current ) { self.goTo(location); } var url = hash(); self.goTo(url || location); } self.goTo = function(location) { var contentPane = dijit.byId('content'); var d = new Deferred(); if ( current == location ) { d.resolve(); return d.promise; } current = location; hash(location); xhr.get({ url: 'pages/'+location+'/'+location+'.html' }) .then(function(content){ contentPane.set('content',content); d.resolve(); },function(){ contentPane.set('content',"Page "+location+" not found."); d.reject(); }); return d.promise; } init(); })(); });