Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.42 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to separate some response data from model on backbone.js callbacks
  2. { message: "Successful post", post: { id: 13, text: "test" } }
  3.        
  4. post = new Post({..})
  5. post.save({}, {
  6.   success: function(post, xhr) {
  7.      data = jQuery.parseJSON(xhr.responseText)
  8.      alert(data.message)
  9.   }
  10. })
  11.        
  12. { message: "Successful post", id: 13, text: "test" }
  13.        
  14. parse : function(resp, xhr) {
  15.   alert resp.message;
  16.   return resp.post;
  17. },