2011-11-29 6 views
0

어떻게 todo.js에 추가 필드를 추가합니까?todo.js에 추가 필드 추가

initialize: function() { 
    this.input = this.$("#new-todo"); 
    Todos.bind('add', this.addOne, this); 
    Todos.bind('reset', this.addAll, this); 
    Todos.bind('all', this.render, this); 

    Todos.fetch(); 
}, 

위의 코드는 문제가 있다고 생각합니다. # new-todo는 텍스트 필드가있는 div id입니다.

'this.input'을 새 필드의 ID와 함께 추가하지만 가져 오지 않습니다. 추가 요소는 어떻게 추가합니까?

답변

0

나는 this.$이보기에 연결된 요소 아래에서만 검색한다고 생각합니다. 보기가 연결된 요소 외부에 입력 요소가있는 경우 $("#another-todo") 또는 그와 비슷한 것을 사용해 볼 수 있습니다.

+0

이 마음에 드십니까? this.inputto = $ ("another-todo") – user901790

+0

아니요, 이렇게 :'this.anothertodo = $ ("# another-todo")'나는 당신을 올바르게 이해합니다. –

+0

이것은 작동하지 않습니다. 어떻게 든 저는 전체 코드를 보낼 수 있습니다. – user901790