javascript - How to get backbone model attributes without .get -


in backbone seems have model attributes via model.get('att_name')

i'd prever them way i'd public field within object: model.att_name

can think of way around this?

eg: in python world override getattr on model this:

def getattr(self, att):    return self.get(att) 

oh, , i'm using coffeescript

model attributes use get() , set() or defaults get/set stored in instance.attributes attribute.

also, these attributes going passed , returned sync() tojson(). when fetch(), save() etc, stored in instance.attributes gets passed along.

nothing stop of course having normal attributes instance.foo on objects. if want treat other attributes , pass these along fetch() , save() can providing custom parse() on model default nothing. said, should if deem absolutely necessary, if comply backbone conventions.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -