Quantcast
Viewing all articles
Browse latest Browse all 3491

Model save parameters

If I had a model with update defined:

  1. update: 'PUT /api/documents/{_id}?action={action}',

to save with PUT request to /api/documents/1234?action=publish I do:

  1. modelInstance.attr('action', 'publish')
  2. modelInstance.save(function(){
  3.       modelInstance.attr('action','')
  4. })


It will put this parameter in request ("?action=..") despite action is empty (or undefined). And it is not very convenient to set this temporary attribute on instance before save action (after save I usually need remove it.

How do you treat such cases? 

Maybe add parameter to save function:

  1. modelInstance.save({action: 'publish'}) 

that would add parameter to request?

What do you think?

Viewing all articles
Browse latest Browse all 3491

Trending Articles