代码中可以看出,这个的作用是在发生改变的时候,不管值是否和原来相同,都触发field_changed事件
xxxxxxxxxx
1
_setValue: function (value, options) {
2
// we try to avoid doing useless work, if the value given has not
3
// changed. Note that we compare the unparsed values.
4
if (this.lastSetValue === value || (this.value === false && value === '')) {
5
return $.when();
6
}
7
this.lastSetValue = value;
8
try {
9
value = this._parseValue(value);
10
this._isValid = true;
11
} catch (e) {
12
this._isValid = false;
13
this.trigger_up('set_dirty', {dataPointID: this.dataPointID});
14
return $.Deferred().reject();
15
}
16
// 下面这个地方
17
if (!(options && options.forceChange) && this._isSameValue(value)) {
18
return $.when();
19
}
20
var def = $.Deferred();
21
var changes = {};
22
changes[this.name] = value;
23
this.trigger_up('field_changed', {
24
dataPointID: this.dataPointID,
25
changes: changes,
26
viewType: this.viewType,
27
doNotSetDirty: options && options.doNotSetDirty,
28
notifyChange: !options || options.notifyChange !== false,
29
onSuccess: def.resolve.bind(def),
30
onFailure: def.reject.bind(def),
31
});
32
return def;
33
},
已复制