Ho uno scenario in cui i dati manipolati sul client vengono presentati e interagiti in modo diverso rispetto a quello che è rappresentato sul server.Proprietà calcolate in Backbone
Considerare la seguente risorsa event
restituita dal server.
{
"id": 123,
"start_at": 1331336004906,
"end_at": 1331337704906
}
E il seguente modello per la modifica:
<form>
<!-- Notice how date and time are separated in the interface -->
<input type="text" name="start_date" value="{{start_date}}" />
<input type="text" name="start_time" value="{{start_time}}" />
<!-- Instead of asking for an end date/time, we ask for the duration -->
<input type="text" name="duration" value="{{duration}}" />
<input type="submit" />
</form>
Come potrei fare per il trattamento start_date
, start_time
, e duration
come attributi nel mio modello Backbone senza inviarli al server? Dovrei modificare .toJSON()
?
Qual è il problema con il formato ressource evento, arent hanno timestamp? – mpm
Vedi anche: http://stackoverflow.com/questions/10648990/how-to-access-a-calculated-field-of-a-backback-model-from-handlebars-template –