2012-04-03 12 views

cevap

4

Sen transaction_test.js karşılık gelen testlerle transaction.js tanımlanan transaction 's kullanabilirsiniz. yerine

App.store = DS.Store.create(...); 

App.User = DS.Model.extend({ 
    name: DS.attr('string') 
}); 

var transaction = App.store.transaction(); 
transaction.createRecord(App.User, { 
    name: 'tobias' 
}); 

App.store.commit(); // does not invoke commit 
transaction.commit(); // commit on store is invoked​ 
1

Çağrı CreateModel:

bir örnek here görün!

Örnek:

// This is a persisted object (will be saved upon commit) 
var persisted = App.store.createRecord(App.Person, { name: "Brohuda" }); 

// This one is not associated to a store so it will not 
var notPersisted = App.store.createModel(App.Person, { name: "Yehuda" }); 

Bunu senin için http://jsfiddle.net/Qpkz5/269/ yaptık.

+0

Veri havuzunun indirmeler bölümünden 'ember-latest.js' komutunu kullanıyorsunuz. Bu dosya 2 ay önce (2011-01-30) yüklendi ve güncel değil. Bu yöntemi master'dan kodda bulamadım. – pangratz

+0

Yani 'ember-data-latest.js' ... – pangratz

+0

@pangratz haklı, bunun değişmiş olduğunu fark etmemiştim. Ona – Luan

0

_create: App.MyModel._create() - modelini kendi durum yöneticisi ile ilişkilendirir, böylece App.store.commit() hiçbir şey yapmayacaktır.

Ancak, _create "özel" dir. Bu kullanım durumu için bir kamu yöntemi olması gerektiğini düşünüyorum.

+0

Kudos İşte Github sorun: https://github.com/emberjs/data/issues/259 –

İlgili konular