Вы можете использовать jQuery.address (http://www.asual.com/jquery/address/) для управления своими URL-адресами.
jQuery.address позволяет устанавливать просматриваемые URL-адреса, например "http://example.com/#!/user/5", и прослушивать адресменяется и действует соответственно.
В своем собственном коде я настроил маршрутизатор на основе адресов из файла конфигурации кражи следующим образом.
steal.plugins(
'jquery/controller',
'jquery/controller/subscribe',
'jquery/view/ejs',
'jquery/controller/view',
'jquery/model',
'jquery/dom/fixture',
'jquery/dom/form_params',
'steal/less')
.css('css/vendor/reset-fonts-grids')
.resources('vendor/jquery.address-1.3.1.min.js')
.models('user')
.controllers('user')
.views()
.then(function() {
steal.less('css/style');
// Set up a router
$.address.baseURL('/basePath');
// $.address.crawlable(true);
$.address.change(function(event) {
var path = event.path;
switch(true) {
// Matches http://example.com/#!/ or http://example.com/
case /^\/$/.test(path):
$('#page').empty();
break;
// Matches http://example.com/#!/user/42/profile
case /^\/user\/[0-9]+\/profile/.test(path):
var userId = path.split("/")[2];
// Instantiate and load a controller
new User.Controllers.User($('body'),userId);
break;
case /^\/search/.test(path):
$.log('search');
break;
default:
$.log(event.path);
}
});
});
Затем можно вызвать новую страницу из HTMLземля через
<a href="/" onclick="$.address.value('/'); return false;">root url</a>
или из земли JS через
$.address.value('/user/10/profile');