!更正
绑定不是它。当你添加到你的模式中时,你会逐渐产生缺少值的不一致(在我的例子中为关系)。我的.create()调用以这样的方式触及Parse/Mongo,即模型绑定要求重新启动主视图。简便的解决方案:在一段时间:)Unbinding .create()
一次擦拭您的数据......
我的主要观点有_.bindAll(this, 'addOne', 'addAll', 'render', 'logOut', '...');
另一种观点认为我设置使用这2种链式方法Parse.Relation:
1 // If you hit return in the add friend input field, create new Email model
2 // and friend it
3 addFriendOnEnter: function(e) {
4 var self = this;
5 console.log("About to create email "+self.emailInput.val());
6 self.emails.create(
7 {
8 email: self.emailInput.val(),
9 ACL: new Parse.ACL(Parse.User.current())
10 },
11 {
12 success: function (email) {
13 console.log("Email added "+email.get("email"));
14 self.addFriend(email);
15 }
16 },
17 {
18 silent:true
19 }
20 );
21 console.log("Created email");
22 },
23
24 addFriend: function(email) {
25 console.log("Add friend relation to topic "+email.get("email"));
26 this.friendsRel.add(email);
27 console.log("Save topic");
28 this.options.topic.save({silent:true});
29 console.log("Render friend");
30 this.renderOneFriend(email);
31 console.log("Clear input val");
32 this.emailInput.val('');
33 },
我看到的最后一个日志是21行,好像addFriend没有被调用,基本上应用程序刷新自己,即我被抛回到重新呈现自己的主视图。
我怀疑的一个方向是主视图绑定到任何模型更改,包括.create()调用。
如何解除该特定呼叫?
感谢, 刚
谢谢这些是真棒指针,特别是关于沉默:true和分解.create()到.add()和.save()。原来,我的老行是问题。 – 2012-07-20 21:17:31