Editable: avoid setTimeout
It's easily avoided and clearer without it.
This commit is contained in:
parent
ec85c7b458
commit
84b3c34130
1 changed files with 14 additions and 14 deletions
|
@ -59,13 +59,13 @@ Ox.Editable = function(options, self) {
|
|||
setCSS({width: self.options.width + 'px'});
|
||||
},
|
||||
highlight: function() {
|
||||
self.$value.html(formatValue());
|
||||
formatValue();
|
||||
},
|
||||
placeholder: function() {
|
||||
self.$value.html(formatValue());
|
||||
formatValue();
|
||||
},
|
||||
value: function() {
|
||||
self.$value.html(formatValue());
|
||||
formatValue();
|
||||
self.$input && self.$input.options({value: formatInputValue()});
|
||||
}
|
||||
})
|
||||
|
@ -99,8 +99,8 @@ Ox.Editable = function(options, self) {
|
|||
self.css = {};
|
||||
self.$value = Ox.Element(self.options.type == 'input' ? '<span>' : '<div>')
|
||||
.addClass('OxValue')
|
||||
.html(formatValue())
|
||||
.appendTo(that);
|
||||
formatValue();
|
||||
|
||||
if (self.options.editing) {
|
||||
// need timeout so that when determining height
|
||||
|
@ -127,13 +127,14 @@ Ox.Editable = function(options, self) {
|
|||
self.options.value = self.originalValue;
|
||||
self.$input.value(formatInputValue()).hide();
|
||||
self.$test.html(formatTestValue());
|
||||
self.$value.html(formatValue()).show();
|
||||
formatValue();
|
||||
self.$value.show();
|
||||
that.triggerEvent('cancel', {value: self.options.value});
|
||||
}
|
||||
|
||||
function change(data) {
|
||||
self.options.value = parseValue(data.value);
|
||||
self.$value.html(formatValue());
|
||||
formatValue();
|
||||
self.$test.html(formatTestValue());
|
||||
setSizes();
|
||||
}
|
||||
|
@ -234,13 +235,11 @@ Ox.Editable = function(options, self) {
|
|||
value, self.options.highlight, 'OxHighlight', true
|
||||
);
|
||||
}
|
||||
// timeout needed since formatValue is used when assinging self.$value
|
||||
setTimeout(function() {
|
||||
|
||||
self.$value.html(value);
|
||||
self.$value[
|
||||
self.options.value === '' ? 'removeClass' : 'addClass'
|
||||
]('OxSelectable');
|
||||
})
|
||||
return value;
|
||||
}
|
||||
|
||||
function parseValue() {
|
||||
|
@ -292,7 +291,8 @@ Ox.Editable = function(options, self) {
|
|||
that.removeClass('OxEditing');
|
||||
self.$input.value(formatInputValue()).hide();
|
||||
self.$test.html(formatTestValue());
|
||||
self.$value.html(formatValue()).show();
|
||||
formatValue();
|
||||
self.$value.show();
|
||||
that.$tooltip && that.$tooltip.options({title: self.options.tooltip});
|
||||
that.triggerEvent('submit', {value: self.options.value});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue