Imagine that I have a view, and as part of a view it render ‘x’ model objects, and ‘x’ only. The question, where is it appropriate for me to put this view related constant?
My guess would be to do something like this:
myApp.MyView = Backbone.View.extend({
...
myConstant: 10,
...
render: function(){
...
//some code that uses myConstant
...
}
});
Does this make sense?
Any suggestions help!
It sounds like what you want to do is to assign a class property to the view. You can pass a second hash into your extend call to do this. Your code would look something like this:
where your constant is accessible as myApp.MyView.myConstant.