를 초기화 backbone.js 모델에 의존 $를 만드는 방법은 다음과 backbone.js 응용 프로그램 초기화 과정이있다 : 응용 프로그램이 $ .ajaxSetup를 초기화 다음는 .ajaxSetup 나중에
var app = {
init: function(arg) {
$.when(app.loadStaticFiles('any_file_to_load_before'))
.done(function(args) {
app.models.current_user = app.Models.User();
});
// ...
// initializing the backbone app and models
// ...
$.ajaxSetup({
headers: {Authorization: 'Token token=' + app.models.current_user.get('token')}
})
}
}
$(document).ready(
function(){
app.init(args);
};
);
는 app.models.current_user.get('token')
을 평가하는 슬프게 IS 정의되지 않았습니다.
디자인에 몇 가지 미스가있는 것 같아요. 어떻게 작동하도록 코드를 다시 작성해야합니까?
$.deferred
해상도 전에 $.ajaxSetup()
의 주된 문제가 있다고 생각합니다.