display: false, element text does not change
This commit is contained in:
2
grunt.js
2
grunt.js
@ -100,7 +100,7 @@ module.exports = function(grunt) {
|
||||
|
||||
//module for testing
|
||||
var module = '';
|
||||
module = '&module=textarea';
|
||||
// module = '&module=textarea';
|
||||
//module = '&module=select';
|
||||
//module = '&module=text';
|
||||
|
||||
|
@ -109,6 +109,10 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
@method render()
|
||||
*/
|
||||
render: function() {
|
||||
//do not display anything
|
||||
if(this.options.display === false) {
|
||||
return;
|
||||
}
|
||||
//if it is input with source, we pass callback in third param to be called when source is loaded
|
||||
if(this.input.options.hasOwnProperty('source')) {
|
||||
return this.input.value2html(this.value, this.$element[0], this.options.display);
|
||||
@ -207,6 +211,11 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
* set emptytext if element is empty (reverse: remove emptytext if needed)
|
||||
*/
|
||||
handleEmpty: function () {
|
||||
//do not handle empty if we do not display anything
|
||||
if(this.options.display === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
var emptyClass = 'editable-empty';
|
||||
//emptytext shown only for enabled
|
||||
if(!this.options.disabled) {
|
||||
@ -547,12 +556,13 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
value: null,
|
||||
/**
|
||||
Callback to perform custom displaying of value in element's text.
|
||||
If not defined, default input's value2html() will be called.
|
||||
If <code>null</code>, default input's value2html() will be called.
|
||||
If <code>false</code>, no displaying methods will be called, element's text will no change.
|
||||
Runs under element's scope.
|
||||
Second parameter __sourceData__ is passed for inputs with source (select, checklist).
|
||||
|
||||
@property display
|
||||
@type function
|
||||
@type function|boolean
|
||||
@default null
|
||||
@since 1.2.0
|
||||
@example
|
||||
|
@ -481,4 +481,28 @@ $(function () {
|
||||
|
||||
});
|
||||
|
||||
asyncTest("display: false", function () {
|
||||
var newText = 'cd<e>;"',
|
||||
e = $('<a href="#" data-pk="1" data-url="post.php" data-name="text1" data-value="abc"></a>').appendTo(fx).editable({
|
||||
display: false
|
||||
});
|
||||
|
||||
ok(!e.text().length, 'element still empty, autotext did not display value');
|
||||
|
||||
e.click()
|
||||
var p = tip(e);
|
||||
|
||||
p.find('input').val(newText);
|
||||
p.find('form').submit();
|
||||
|
||||
setTimeout(function() {
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
ok(!e.text().length, 'element still empty, new value was not displayed');
|
||||
equal(e.data('editable').value, newText, 'new text saved to value');
|
||||
e.remove();
|
||||
start();
|
||||
}, timeout);
|
||||
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user