fixes #141: data-value igoned for empty element
This commit is contained in:
@ -5,6 +5,7 @@ X-editable changelog
|
||||
|
||||
Version 1.4.2 wip
|
||||
----------------------------
|
||||
[bug #141] data-value ignored for empty elements (vitalets)
|
||||
[bug #137] fix empty class for delegated element (vitalets)
|
||||
[enh #121] add support of momentjs 2.0.0 in combodate (vitalets)
|
||||
|
||||
|
@ -26,7 +26,7 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
//name
|
||||
this.options.name = this.options.name || this.$element.attr('id');
|
||||
|
||||
//create input of specified type. Input will be used for converting value, not in form
|
||||
//create input of specified type. Input need already here to convert value for initial display (e.g. show text by id for select)
|
||||
this.input = $.fn.editableutils.createInput(this.options);
|
||||
if(!this.input) {
|
||||
return;
|
||||
@ -77,9 +77,19 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
}
|
||||
|
||||
//check conditions for autotext:
|
||||
//if value was generated by text or value is empty, no sense to run autotext
|
||||
doAutotext = !isValueByText && this.value !== null && this.value !== undefined;
|
||||
doAutotext &= (this.options.autotext === 'always') || (this.options.autotext === 'auto' && !this.$element.text().length);
|
||||
switch(this.options.autotext) {
|
||||
case 'always':
|
||||
doAutotext = true;
|
||||
break;
|
||||
case 'auto':
|
||||
//if element text is empty and value is defined and value not generated by text --> run autotext
|
||||
doAutotext = !$.trim(this.$element.text()).length && this.value !== null && this.value !== undefined && !isValueByText;
|
||||
break;
|
||||
default:
|
||||
doAutotext = false;
|
||||
}
|
||||
|
||||
//depending on autotext run render() or just finilize init
|
||||
$.when(doAutotext ? this.render() : true).then($.proxy(function() {
|
||||
if(this.options.disabled) {
|
||||
this.disable();
|
||||
|
@ -17,6 +17,7 @@ $(function () {
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
});
|
||||
|
||||
|
||||
asyncTest("should load correct value and save new entered text (and value)", function () {
|
||||
var v = 'ab<b>"',
|
||||
esc_v = $('<div>').text(v).html(),
|
||||
|
Reference in New Issue
Block a user