Hi could somebody give me an understandable example of a requirejs singleton with underscore’s once()?
I have this as far:
define(['jquery', 'underscore', 'backbone'], function($, _, Backbone) {
var SingletonModel = Backbone.Model.extend({
urlRoot: "/model",
idAttribute: "_id"
});
return function() {
once(SingeletonModel);
};
});
As you see especially the return statement is totally crap. I just have no idea how to singletony a Backbone.Model…
I’m doing this
then you just require this file and use it as it would be an instance.
EDIT:
Haven’t tried it, but the usage of once() should be in your case