Skip to content

Commit 0071318

Browse files
committed
Editable: Fixed start method. A previous edit could be lost when start was called.
1 parent 5240b3b commit 0071318

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

ui/jquery.ui.editable.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ $.widget( "ui.editable", {
4949
},
5050

5151
start: function() {
52-
this._edit();
52+
if ( !this._editing ) {
53+
this._edit();
54+
}
5355
},
5456

5557
submit: function() {
@@ -92,7 +94,7 @@ $.widget( "ui.editable", {
9294

9395
this.element.removeClass( highlightStateClass );
9496

95-
if ( !this.editing && ( $this.is( this.element ) || $this.hasClass( placeholderClass ) ) ) {
97+
if ( !this._editing && ( $this.is( this.element ) || $this.hasClass( placeholderClass ) ) ) {
9698
this.element.addClass( highlightStateClass );
9799
return;
98100
}
@@ -108,12 +110,12 @@ $.widget( "ui.editable", {
108110
},
109111

110112
_show: function() {
111-
this.editing = undefined;
113+
this._editing = undefined;
112114
this.element.html( this.value() || this._placeholder() );
113115
},
114116

115117
_edit: function() {
116-
this.editing = true;
118+
this._editing = true;
117119
this.element.html( this._form() );
118120
this._formEvents();
119121
},
@@ -126,7 +128,7 @@ $.widget( "ui.editable", {
126128

127129
_form: function() {
128130
var editor = $.ui.editable.editors[ this.options.editor ],
129-
form = $( "<form></form>" )
131+
form = $( "<form></form>" )
130132
.addClass( formClass )
131133
.append( $( "<span></span>" )
132134
.append( editor.element( this )));
@@ -156,7 +158,7 @@ $.widget( "ui.editable", {
156158

157159
_formEvents: function() {
158160
var self = this,
159-
editor = $.ui.editable.editors[ self.options.editor ];
161+
editor = $.ui.editable.editors[ self.options.editor ];
160162
$( "form", this.element )
161163
.submit( function( event ) {
162164
self._save.call( self, event, editor.value( self, this ) );
@@ -239,7 +241,7 @@ $.ui.editable.editors = {
239241
.addClass( inputClass );
240242
},
241243
bind: function( editable ) {
242-
var self = editable;
244+
var self = editable;
243245
$( "input", editable.element )
244246
.focus( function() {
245247
self.frame.addClass( activeStateClass );

0 commit comments

Comments
 (0)