2012-08-09 6 views
3

내 API 서버와 내 웹 사이트에는 2 개의 다른 URL이 있습니다!모든 기본 가져 오기 백본 집합 글로벌 api URL 루트

예컨대 :

define([ 
    'jquery', 
    'backbone', 
    'underscore', 
    'infrastructure/session/session'], 
    function($, backbone, _,session){ 
     var Model = backbone.Model.extend({ 

      urlRoot: "api/user/"+session.userIdConnected+"/biometrics/motion/scores", 

      findFromDate:function (startDate) { 
       this.fetch({ data: $.param({ from: startDate}) }) 
      }, 
      initialize: function(){ 

      } 
     }); 

     return Model; 
    }); 

등뼈가 내 모델에 비해 API 호출 URL을 제공하기 때문에 정상입니다 내 웹 사이트의 URL을 가져옵니다.

어딘가에 모든 API 호출에 대해 전역 URL 루트를 설정할 수 있습니까?

답변

2

나는 this link이 도움이 될 것이라고 생각합니다.

define([ 
    'backbone', 
    '../models/communityModel' 
], function(Backbone, CommunityModel){ 
    return Backbone.Collection.extend({ 
     url: function(){ 
      return myApp.Settings.DefaultURL + '/communities'; 
     }, 
     model: CommunityModel, 
     initialize: function() { 
      // something 
     } 
    }); 
}); 

(URL을 저장하는 myApp.Settings.DefaultURL 전역 변수 포함)

관련 문제