English 中文(简体)
Backbone.js source 改为
原标题:Backbone.js source read-through

我读到背后一.js来源,这些内容有些混淆(L230-238, v0.5.3)

unset : function(attr, options) {
  if (!(attr in this.attributes)) return this;
  options || (options = {});
  var value = this.attributes[attr]; // ?: value appears to be unused (?)

  // Run validation.
  var validObj = {};
  validObj[attr] = void 0; //void 0 is equivalent to undefined
  if (!options.silent && this.validate && !this._performValidation(validObj, options)) return false;

Am I crazy or does the last line run a validation against a hash object with a single undefined attribute?

看来,验证的用意是,根据《示范公约》中删除的“归属-待决”。

现有带标线的灯塔()

最佳回答

你在评估其所做工作时重新正确,但这种评估具有预期的功能。

when you call unset, you can only tell it to unset one attribute at a time: model.unset("myAttr")

在不确定身份时,必须进行验证,以确保该模式成为一个有效的国家。 如果被确定为未界定的属性将使该模式无效,则失败。 如果属性不明确,则属性从模型中删除。

由此得出的“具有单一未界定特性的ash子”的理由是, j中的所有物体都作为“ash子”——关键价值乳制品或关联阵列。 这确实关系到你们如何获得一个物体,它是一个联系阵列。

an object with one empty attribute named after the model s attribute that is being unset, is created in lines 236-237. this is so that monkeying with the object passed into the validate method won t change the state of the model itself.

希望有助于解释问题。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签