Tengo un escenario en el que los datos que se manipulan en el cliente se presentan y se interactúan de una manera diferente a como se representa en el servidor.Propiedades calculadas en backbone
Tenga en cuenta el siguiente recurso event
devuelto por el servidor.
{
"id": 123,
"start_at": 1331336004906,
"end_at": 1331337704906
}
Y la siguiente plantilla para la edición:
<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>
¿Cómo hago para tratar start_date
, start_time
y duration
como atributos en mi modelo Backbone sin enviarlos al servidor? ¿Se supone que debo modificar .toJSON()
?
¿cuál es el problema con el formato ressource evento, que enviaban las marcas de tiempo? – mpm
Vea también: http://stackoverflow.com/questions/10648990/how-to-access-a-calculated-field-of-a-backbone-model-from-handlebars-template –