EntitySpaces / entityspaces.js

A JavaScript Data Access Framework that uses Knockout
www.entityspaces.net
36 stars 11 forks source link

Custom save routes #10

Open lucasjans opened 12 years ago

lucasjans commented 12 years ago

Here's a simple request. Would love to have the ability to utilize custom save roues. Why? There's sometimes special business logic we want to perform when saving records.

I can hack this in right now by modifying the es.objects.NAME.prototype.esRoutes['commit'] before saving and then changing it back after saving, but it would be nice if there was an elegant solution to the one you have here for custom load routes

es.objects.RevCoCompaniesCollection.prototype.loadHostCompanies = function (success, error, state) {
    return this.load({
        route: this.esRoutes['LoadHostCompanies'],
        success: success,
        error: error,
        state: state
    });
};
es.objects.RevCoCompaniesCollection.prototype.esRoutes['LoadHostCompanies'] =  { method: 'GET', url: 'RevCoCompaniesCollection_LoadHostCompanies', response: 'collection' }
lucasjans commented 12 years ago

For what it's worth, I looked at the .save function, but it doesn't accept an argument for the "route."