null value for select not trigger source load
This commit is contained in:
parent
94cee0731a
commit
d56271c021
@ -4,6 +4,7 @@ X-editable changelog
|
||||
|
||||
Version 1.3.1 wip
|
||||
----------------------------
|
||||
[enh] if new value for select is 'null' source should not load (vitalets)
|
||||
[enh #53] 'name' no more appended to source defined as url (vitalets)
|
||||
[enh #46] move 'img' dir outside 'css' (vitalets)
|
||||
[enh #48] fix handling of newlines in textarea input (jmfontaine)
|
||||
|
@ -35,19 +35,23 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
},
|
||||
|
||||
value2html: function (value, element, display) {
|
||||
var deferred = $.Deferred();
|
||||
this.onSourceReady(function () {
|
||||
if(typeof display === 'function') {
|
||||
//custom display method
|
||||
display.call(element, value, this.sourceData);
|
||||
} else {
|
||||
this.value2htmlFinal(value, element);
|
||||
}
|
||||
deferred.resolve();
|
||||
}, function () {
|
||||
//do nothing with element
|
||||
deferred.resolve();
|
||||
});
|
||||
var deferred = $.Deferred(),
|
||||
success = function () {
|
||||
if(typeof display === 'function') {
|
||||
//custom display method
|
||||
display.call(element, value, this.sourceData);
|
||||
} else {
|
||||
this.value2htmlFinal(value, element);
|
||||
}
|
||||
deferred.resolve();
|
||||
};
|
||||
|
||||
//for null value just call success without loading source
|
||||
if(value === null) {
|
||||
success.call(this);
|
||||
} else {
|
||||
this.onSourceReady(success, function () { deferred.resolve(); });
|
||||
}
|
||||
|
||||
return deferred.promise();
|
||||
},
|
||||
|
@ -596,7 +596,34 @@ $(function () {
|
||||
e.remove();
|
||||
start();
|
||||
}, timeout);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
asyncTest("set value to null should not trigger source load", function () {
|
||||
var req = 0;
|
||||
$.mockjax({
|
||||
url: 'groups-null.php',
|
||||
response: function() {
|
||||
req++;
|
||||
}
|
||||
});
|
||||
|
||||
var e = $('<a href="#" data-type="select" data-pk="1" data-name="name1" data-value="1" data-url="post.php" data-source="groups-null.php">11</a>').appendTo(fx).editable(),
|
||||
d = e.data('editable');
|
||||
|
||||
e.editable('setValue', null);
|
||||
|
||||
setTimeout(function() {
|
||||
equal(req, 0, 'no request');
|
||||
equal(e.text(), d.options.emptytext, 'text correct');
|
||||
equal(d.value, null, 'value correct');
|
||||
|
||||
e.remove();
|
||||
start();
|
||||
}, timeout);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user