English 中文(简体)
Backbone.js型 Error 投下模型。 储蓄
原标题:Backbone.js TypeError thrown on model.save

In my current Backbone app, I have no problems creating or destroying models. The changes propagate to my server without any problems. But whenever I try to do a model.save(attributes), I see a TypeError thrown at this line: https://github.com/documentcloud/backbone/blob/master/backbone.js#L117

The model is updated on the (Rails) server, but something breaks afterward. Here s the stack trace. (Sorry, line numbers refer to concatenated JS files.)

Backbone.Events.trigger() at application.js:11574 
_.extend._onModelEvent() at application.js:12092 
d() at (internal script):1426Backbone.Events.trigger() at 
application.js:11574 
_.extend.change() at application.js:11808 
_.extend.set() at application.js:11680 
_.extend.save() at application.js:11753 
Map.mapMoveGeoPointMode() at app.js:741 
(anonymous function)() at app.js:894 
jQuery.event.handle() at application.js:2966 
jQuery.event.add.elemData.handle.eventHandle() at application.js:2600 

In previous applications, I ve had no little problems on saving models like this. Any suggestions for what to look at?

注:我不想再重复。 该研究员试图挽救一个没有URL的模型的问题

最佳回答

鉴于该模型在服务器上得到适当更新,我不认为这与<代码>save(<>/code>功能本身有任何关系,而是与change<>code有关。 如果发生这种事件,我想你可以仅仅通过打电话myModel.trigger(改动)

我对为什么出现这种情况的最佳猜测是,在你重新约束职能以外的某些职能——例如未界定的变数——到<条码>改动活动时,有些地方也如此。 我这样看一看一个错误:

myModel.bind( change , this.misspelledMethod, this);

但是,如果不看到实际的法典,而不仅仅是一种 st痕,就很难进一步推测。

问题回答

它认为,你对关于模式的活动具有约束力,并且通过某种没有有效功能的活动。 3. 确保你的所有约束性声明在职能上通过:

var FUNC = function() {};
MyModel.bind( reset  FUNC);




相关问题
What s the appropriate granularity for Backbone.js Views?

I m adopting Backbone.js to render a small corner of an existing large web app. If this goes well, I can see Backbone.js growing to encompass the whole of the app, lending some much-needed structure ...

Rendering Layouts with Backbone.js

If you were to build a single page web application (SPWA) using Backbone.js and jQuery with--for example--two controllers that each required a unique page layouts, how would you render the layout? ...

Load html without refresh

Im unsure of how to approach this, should I have the html to be loaded hidden or load it from somewhere? I want to load a form in one page, and dynamic content on other pages. The form can be saved ...

Why are my CoffeeScript/backbone.js events not firing?

I m trying to familiarize myself with CoffeeScript and backbone.js, and I must be missing something. This CoffeeScript: MyView = Backbone.View.extend events: { "click" : "testHandler" ...