7
मैं त्रुटि हो रही है:बैकबोन - वस्तु प्रस्तुत करना कोई विधि 'लागू करें' है
object render has no method apply for the below code.
क्या कारण हो सकता है? एचटीएमएल पेज में जावास्क्रिप्ट के लिंक को छोड़कर कोई भी कोड नहीं है।
त्रुटि को हटाने के लिए मुझे क्या करना चाहिए?
(function($) {
window.Book = Backbone.Model.extend({});
window.Library = Backbone.Collection.extend({
model: Book
}); // end of Collection
window.LibraryView = Backbone.View.extend({
el: $('body'),
events: {
'click button#btn_add': 'btn_add'
},
initialize: function() {
$(this.el).append("View initialized");
_.bindAll(this, 'render', 'btn_add');
this.collections = new Library();
this.collections.bind('add', 'render', this);
this.startingDisplay();
},
startingDisplay: function() {
$(this.el).append("<input type='text' id='t1' /><button id='btn_add'>Add</button>");
},
btn_add: function() {
book = new Book({
title: "first"
});
alert("Name : " + book.get('title'));
this.collections.add(book);
},
render: function() {
alert("render called");
},
}); // end of LibraryView
libraryview = new LibraryView();
})(jQuery);
बहुत बहुत शुक्रिया, महान काम कर रहा! – user1305989
मुझे रेंडर फ़ंक्शन में "यह" क्यों वापस करना चाहिए? यह क्या करता है ? – user1305989
तो यह श्रृंखला योग्य है, इस प्रकार आप 'myView (someModel) .render() el' कर सकते हैं। मुख्य दृश्य में यह दिलचस्प नहीं हो सकता है लेकिन जब आपके पास कोई विचार है तो यह आसान हो जाता है - मान लें - एक संपर्क Item। –