URL을 관리하려면 jQuery.address (http://www.asual.com/jquery/address/)를 사용하는 것이 좋습니다.
jQuery.address를 사용하면 "http://example.com/#!/user/5"와 같은 크롤링 할 수있는 URL을 설정하고 주소 변경 사항을 수신하고 이에 따라 조치를 취할 수 있습니다.
내 자신의 코드에서 다음과 같이 steal 구성 파일 내에서 주소 기반 라우터를 설정합니다.
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);
}
});
});
당신은 다음 jQuery를 같은 동일합니다, 당신은 JavascriptMVC 라우터를 사용할 수 있습니다
$.address.value('/user/10/profile');
출처
2011-01-08 05:30:52
asm