2013-03-17 4 views
1

백본과 Django Rest Framework를 사용하여 응용 프로그램을 만들려고하고 있는데이 템플릿을 렌더링 할 때이 문제가 있습니다. 나는 다음과 같은 얻을 오류 :백본에서 파일 렌더링 문제가 발생했습니다.

Uncaught TypeError: object is not a function

백본

var EditBook = Backbone.View.extend({ 
el:'.page', 
render: function (options) { 
    var that = this; 
    if(options.id) { 
     var book = new Book({id: options.id}); 
     book.fetch()({ 
      success: function(book) { 

       var template = _.template($('#edit-book-template').html(), {book: null}); 
       that.$el.html(template); 
      } 
     }) 
    } else { 
     var template = _.template($('#edit-book-template').html(), {book: null}); 
     this.$el.html(template); 
    } 
} 
}); 

나는 프로그램의 제어 흐름을 확인 시도하고 줄에서 오류 점과 같습니다 success: function(book){ 거기하지 않는 것 오류가 될 수 있습니다. 근본적으로 백본에 익숙하며 모든 구석에서 도움을 구하기 때문에 친절하게 도움을줍니다.

편집 : 문제가 해결되었으므로 관련없는 코드가 제거되었습니다.

답변

1

fetch 결과를 함수로 호출하고 있습니다.

변경 라인 :

book.fetch()({ 
    success: function(book) { 
     var template = _.template($('#edit-book-template').html(), {book: null}); 
     that.$el.html(template); 
    } 
}) 

로는 :

book.fetch({ 
    success: function(book) { 
     var template = _.template($('#edit-book-template').html(), {book: null}); 
     that.$el.html(template); 
    } 
}); 
+0

내 눈을 놓친해야합니다. 고마워. –