Model Defaults and Events
Get an overview of how model defaults and events can be specified and used in Marionette.
We'll cover the following
Using model defaults
What do we do if our contact doesn't have a first name? We don’t want our app to break if the firstName
attribute is missing since the template would be trying to retrieve an attribute that doesn’t exist on the model.
How can we manage this case? The functionality we’re looking for are default values for model attributes.
To declare default attribute values, simply add a defaults
object to the main object provided in our model definition:
Get hands-on with 1400+ tech skills courses.