In backbone it seems that I have to get model attributes via model.get('att_name')
I’d prever to get them the way I’d get any public field within an object: model.att_name
Can anyone think of a way to get around this?
eg: In python world I would override getattr on the model something like this:
def getattr(self, att):
return self.get(att)
Oh, and I’m using CoffeeScript
Model attributes that you use
get()andset()ordefaultsto get/set are stored in theinstance.attributesattribute.Also, these are the attributes that are going to be passed to and returned from
sync()as well astoJSON(). So when youfetch(),save()etc, only what is stored ininstance.attributesgets passed along.Nothing will stop you of course from having normal attributes like
instance.fooon your objects. If you want to treat those as the other attributes and pass these along tofetch()andsave()you can do so by providing a customparse()on your model which by default does nothing. That said, you should only do this if you really deem it absolutely necessary, if only to comply to the Backbone conventions.