Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Model save parameters

$
0
0
Well, I wouldn't necessarily say that you should make two separate requests, only that you should maintain a consistent restful api. One issue with trying to merge the two functionalities is that it blurs the meaning of your response message, which now might not be resource-specific, and might not be consistent between your additional parameters. At the very least, a reasonable approach is to maintain a standardized save endpoint, and a separate update & publish endpoint.

In any case, you can add in an ajax request method, or otherwise override save:

  1. save: function( query ) {
  2.       return can.ajax({
  3.             url: can.sub('foo/{id}.json/?{query}', {
  4.                   id: this.id,
  5.                   query: can.param(query)
  6.             type: 'PUT',
  7.             data: this.serialize(),
  8.             dataType: 'json'
  9.       });
  10. }) 


Viewing all articles
Browse latest Browse all 3491

Trending Articles