HTML and CSS Reference
In-Depth Information
message: "The format property in the videosource model requires
a 'app.type.format' type",
type: "validation_exception"
}
return;
}
_format = format;
}
this.init();
}
Based on this example, you should now be able to add validation to your setters
based on the code comments from this topic. Feel free to add them for each
model.
Creating New Types
The types currently available in JavaScript are great. However, sometimes you
might find yourself in a situation where you would like to pass a structured
object to a model that might not necessarily be a model itself. These are usually
known as types, and have the same structure throughout your application. For
instance, you might want to create a new location type to store location
information and retrieve it in a predictable way.
From the models comments, you would have seen that there are two custom
types in the application: format and releaseDate . format simply allows you to
store a video format so that it's easy to get the mime type, file format (such as
mp4, webm, etc.), and the name of the format for reference. The releaseDate
type simply stores a film's cinema release date and DVD release date.
To create the new types, simply create two new files within the js/app/type
directory called format.js and releaseDate.js . (If the directory doesn't exist,
you should create it.)
In the format.js file, add the following code.
var app = app || {};
app.type = app.type || {};
/**
* The media type, can be used to
* define mime types of objects
* @param {String} name
 
Search WWH ::




Custom Search