2013-11-05 2 views
-1

'POST'라는 모델에 함수를 만들고 POST 요청을 통해 서버에 요청을 보내려합니다 (아래 샘플). 요청을 보내려면 rootUrl에 영향을주지 않고 url을 어떻게 설정할 수 있습니까? 티아!Backbone.JS : 모델의 기능에 대한 사용자 정의 URL

MyModel = Backbone.Model.extend({ 
    urlRoot: '../mymodel' 
    initialize: function(){ 

    }, 
    post: function(){ 
     // how put the url here? 
     // this is the custom url: '../post/mymodel/' + this.model.get('id') 
     // this is the expected log on server: 
     // POST: ../post/mymodel/323133 
}); 

답변

1

그냥 model.collection.urlmodel.url 대의원이 다른

model.url

+0

감사합니다! 하지만 POST를 통해 어떻게 요청할 수 있습니까? – jrsalunga

0
사용할 수

Ajax를 더 읽기에 대한 지정되지 않는 것을 url 대신 urlRoot

주의 사용

post: function(){ 
    $.post('../post/mymodel/' + this.model.get('id'), function(data) { 
     $(".result").html(data); 
    }); 
} 
관련 문제