मेरा बैकबोन एप्लिकेशन शेड्यूल नामक एक दृश्य है, मैं सफलता और त्रुटि पर उचित फ़ंक्शन को कॉल करने के अंतर के बारे में थोड़ा उलझन में हूं, मुझे नीचे सूचीबद्ध दोनों टॉव की कोशिश की गई है, लेकिन मैं नहीं था अंतर क्या है और क्या सही तरीके से बाहर दृश्य में रखा रूटर से एक समारोह कॉल करने के लिए है:बैकबोन लाने का उचित तरीका
पहला तरीका:
require([
'app/collections/schedule',
'app/views/schedule'
], function(ScheduleCollection, ScheduleView) {
var scheduleCollection = new ScheduleCollection(),
scheduleView = new ScheduleView({
model: scheduleCollection
});
scheduleCollection.fetch({
reset: true,
success: function(){
scheduleView.successHandler();
},
error: function(){
scheduleView.errorHandler()
}
});
});
दूसरा तरीका
require([
'app/collections/schedule',
'app/views/schedule'
], function(ScheduleCollection, ScheduleView) {
var scheduleCollection = new ScheduleCollection(),
scheduleView = new ScheduleView({
model: scheduleCollection
});
scheduleCollection.fetch({
reset: true,
success: scheduleView.successHandler(),
error: scheduleView.errorHandler()
});
});
scheduleView
successHandler: function(){
console.log('success');
}
erroHandler: function(){
console.log('error');
}
क्या आपको उन तरीकों को 'शेड्यूल व्यू' में बाध्य करने की आवश्यकता नहीं होगी? 'Console.log' मामले में नहीं, लेकिन यदि उन विधियों का उपयोग' this' ... – nrabinowitz
@nrabinowitz हां, मुझे विश्वास है ... मैं उस पर कभी स्पष्ट नहीं था। – McGarnagle