답변

2

'status'속성이 서버에 설정되어 있다고 가정합니다. 그렇다면 model.save() 호출은 비동기식이며 속성은 완료 될 때까지 사용할 수 없습니다. 액세스하려면, 예를 들어, 저장 호출 할 때 전달 된 성공 콜백으로 결합해야합니다 :

_self = @ 
@model.save success: -> 
    console.log 'Status: ', _self.model.get('status') 

은 또는 당신을 위해, 모든 성공적인 저장 한 후 실행됩니다 모델의 '동기화'이벤트에 바인딩 할 수 있습니다 예 : 답장을 보내 주셔서 너무 감사 @robmisio

@model.on 'sync', (model) -> 
    console.log 'Status: ', model.get('status') 
0

는 난 ... 아무도 나를 위해 일한하지만 알 .. 난이 해결을 사용하는 모두를 시도

connect: (e) -> 
    @model = new IndexModel({country: e.currentTarget.alt, language: window.Language}) 
    $('#spinner_ajax').show() 
    @model.save(null, { 
    success: @success 
    error: @error 
    }) 

error: (xhr, status, thrown) -> 
    console.log "AJAX Error: #{status}" 
    alert "AJAX Error: #{status}: Server is probably down." 
    $('#spinner_ajax').hide(); 
    no 
success: (model) -> 
    console.log "Status: #{model.get('status')}" 
    if model.get('status') 
    window.lmStatus = true 
    window.location.hash = 'connection' 
    $('#spinner_ajax p').html('You are being redirected ') 
    else 
    alert 'This connection is currently not active.' 
    $('#spinner_ajax').hide(); 
    no 
관련 문제