score:0

Accepted answer

After a few hours I finally came up with a working solution. I started with the save command:

model.save({command:'approve'})

And then I overrode backbone's ajax command:

    Backbone.ajax = function () {
    var args = Array.prototype.slice.call(arguments, 0);

    if (args[0].data) {
        var model = JSON.parse(args[0].data);
        var command = model.command;
        if (command) {
            args[0]['headers'] = { command: command};
        }
    }

    return Backbone.$.ajax.apply(Backbone.$, args);
}

This code looks for the command value on the model (Backbone.save put it there), and pushes it to the headers. The next step will be to simply remove the command from the model before returning it.

score:1

You could tackle this a couple of different ways.

You could override Backbone syncwith your own implementation, as described here. Within your sync implementation, you would pull out certain params (like approve), and jam them into the URL.

Or you could override the Model.url.


Related Query

More Query from same tag