Skip to content

Commit

Permalink
reorganize SC.CloseFieldEditor() to reduce possibilty of interference…
Browse files Browse the repository at this point in the history
… if it is invoked while dispatching
  • Loading branch information
erichocean committed May 14, 2012
1 parent 42d23f4 commit 0954460
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions application/text/field_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,16 @@ SC.CloseFieldEditor = function() {
sc_assert(input);
sc_assert(document.getElementById(input.id));

SC.activeEditor = null;
editor.widget = null;
SC.app.set('fieldEditor', null);

var value = input.value,
old;

input.style.display = 'none';
document.body.appendChild(input);

if (widget.valueForFieldEditor) {
old = widget.valueForFieldEditor();
} else {
Expand All @@ -271,17 +278,12 @@ SC.CloseFieldEditor = function() {

if (old !== value) {
if (widget.takeValueFromFieldEditor) widget.takeValueFromFieldEditor(value);
else widget.set('value', value);
else {
widget.set('value', value);
}
}

widget.tryToPerform('fieldEditorDidClose');

SC.activeEditor = null;
editor.widget = null;
SC.app.set('fieldEditor', null);

input.style.display = 'none';
document.body.appendChild(input);
};

SC.ready(function() {
Expand Down

0 comments on commit 0954460

Please sign in to comment.