2011-01-05 5 views
0

현재 응용 프로그램을 JavascriptMVC + RESTfull 웹 서비스를 사용하도록 이식 할 생각입니다. 그러나 JavascriptMVC로 북마크 가능한 URL을 만들 수 있는지 확실하지 않습니다. 예를 들어JavascriptMVC는 북마크 가능한 URL을 지원합니까?

: 웹 애플리케이션 1

는 JavascriptMVC와 같은 URL을 만들 수 있습니다/교육 과정을 호스팅하는 응용 프로그램이며,

/코스/RDBMS/강의와 같이 URL이 있습니까?

답변

2

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'); 
3

를 통해

<a href="/" onclick="$.address.value('/'); return false;">root url</a> 

를 통해 또는 JS의 땅에서 HTML-땅에서 새 페이지를 호출 할 수 있습니다. 주소가 있지만 자바 스크립트와 통합되어 있습니다 .VC : http://javascriptmvc.com/docs.html#!jQuery.route