I’m new to require/backbone developpment, and I what I’ve red two ways to write Views :
1st id :
define([
'jquery',
'backbone',
'underscore'
], function($, Backbone, _){
var View = Backbone.View.extend({
...
});
return View;
});
2nd is :
define([
'jquery',
'backbone',
'underscore'
], function($, Backbone, _){
var View = Backbone.View.extend({
...
});
return new View;
});
3rd is :
define([
'jquery',
'backbone',
'underscore'
], function($, Backbone, _){
var View = Backbone.View.extend({
...
});
});
Is there someone explain me what’s the difference between those 3 way of writing views ?
Thanks a lot in advance.
The first example will return an object that you can instantiate, a class if you like.
The second will return what is essentially a singleton as subsequent calls to require will return the same object;
The last wont return anything, I’m not 100% sure but I think its pretty useless.