Attributes contains a list of properties and their types for this model. You can use this in conjunction with jQuery.Model.convert to provide automatic type conversion.
The following converts dueDates to JavaScript dates:
$.Model("Contact",{
attributes : {
birthday : 'date'
},
convert : {
date : function(raw){
if(typeof raw == 'string'){
var matches = raw.match(/(\d+)-(\d+)-(\d+)/)
return new Date( matches[1],
(+matches[2])-1,
matches[3] )
}else if(raw instanceof Date){
return raw;
}
}
}
},{})