0
Treehouse의 Backbone.js 튜토리얼에 문제가 있습니다. 여기에 내 코드입니다 :정의되지 않은 'new_form'속성을 설정할 수 없습니다.
var NotesApp = (function() {
var App = {
stores: {}
}
App.stores.notes = new Store('notes');
// Note Model
var Note = Backbone.Model.extend({
//Local Storage
localStorage: App.stores.notes,
initialize: function() {
if (!this.get('title')) {
this.set({
title: "Note at " + Date()
})
};
if (!this.get('body')) {
this.set({
body: "No Body"
})
};
}
})
//Views
var NewFormView = Backbone.View.extend({
events: {
"submit form": "createNote"
},
createNote: function (e) {
var attrs = this.getAttributes(),
note = new Note();
note.set(attrs);
note.save();
},
getAttributes: function() {
return {
title: this.$('form [name=title]').val(),
body: this.$('form [name=body]').val()
}
}
});
window.Note = Note;
$(document).ready(function() {
App.views.new_form = new NewFormView({
el: $('#new')
});
})
return App
})();
그리고 나는 오류를 얻을 : Cannot set property 'new_form' of undefined
내가 다시 가서 최대한 가까이 코드를 복사하려했지만, 나는 아직도 그 일을 가져올 수 없습니다. 어떤 제안?
감사합니다, 당신의 제안이 도움이 더 vivification이 없습니다. 하지만 지금은 또 다른 오류가 발생합니다 : Uncaught SyntaxError : 예기치 않은 토큰} http://pastebin.com/SKi3UsKB – Mike
'views {}'이 아닌'views : {}'입니다. – Ven
죄송합니다! 고마워, 콘솔에 오류가 없습니다! – Mike