jquery - Backbone Model Save with Specific Attributes, How to Post some attrs when syncing? -


i've got new model tons of attributes. when #saveing expect backbone #post because id null, works correctly.

$ = require('jquery') - = require('underscore')  model = new backbone.model({   id: null,   name: "tom",   cat: false,   dog: true,   //... many more attrs   whiskers: false,   tail: true }); 

now want send small subset of attributes server on post.

with jquery can write this:

data = _.pick(model.attributes, 'name', 'dog', 'tail'); $.post(model.url(), data); 

how can backbone?

i did sync below, felt wrong.

data = {} data.attrs = _.pick(model.attributes, 'name', 'dog', 'tail'); model.sync('create', model, data) 


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -