I'm using Backbone with RESTful persistence.
Is it possible to define some arbitrary input parameters for a Backbone Collection create() method? Normally, Backbone expects corresponding model as input parameter.
Example:
Model "Adder" has the following attributes: "id", "date" and "sum"
I would like to create an instance of these model (via corresponding collections' create() method) by passing 3 parameters: a, b, c. Backend would then calculate the sum=a+b+c and create a record with a calculated sum. It should return a valid Model object and add it to collection.
So...
POST api/adder 1, 2, 3
Retured JSON:
{
"id": 153235,
"date": "11/11/11",
"sum": 6
}
UPDATE:
Maybe will this, less extreme eample help. How can I send additional parameters to a POST method, besider the model's atts?
If a model is:
{
a: 1,
b: 2,
c:3
}
I would like to send one parameter more, something like calculation_mode, that does not exist in the model itself.
Can I do that?