cancelnochange option
This commit is contained in:
parent
07c328feeb
commit
2809edb3a6
@ -181,7 +181,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
|
||||
//if value not changed --> cancel
|
||||
/*jslint eqeq: true*/
|
||||
if (newValueStr == this.input.value2str(this.value)) {
|
||||
if (this.options.cancelnochange && newValueStr == this.input.value2str(this.value)) {
|
||||
/*jslint eqeq: false*/
|
||||
this.cancel();
|
||||
return;
|
||||
@ -472,7 +472,16 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
@default null
|
||||
@since 1.1.2
|
||||
**/
|
||||
scope: null
|
||||
scope: null,
|
||||
/**
|
||||
Whether to cancel or submit value when it was not changed.
|
||||
|
||||
@property cancelnochange
|
||||
@type boolean
|
||||
@default true
|
||||
@since 1.1.2
|
||||
**/
|
||||
cancelnochange: true
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -389,6 +389,64 @@
|
||||
}, timeout);
|
||||
|
||||
});
|
||||
|
||||
asyncTest("cancelnochange: true", function () {
|
||||
var v = 'abc',
|
||||
e = $('<a href="#" data-type="text" data-pk="1" data-url="post-no.php" data-name="text1">'+v+'</a>').appendTo(fx).editable({
|
||||
cancelnochange: true
|
||||
}),
|
||||
req = 0;
|
||||
|
||||
$.mockjax({
|
||||
url: 'post-no.php',
|
||||
response: function() {
|
||||
req++;
|
||||
}
|
||||
});
|
||||
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
ok(p.is(':visible'), 'popover visible');
|
||||
p.find('input[type="text"]').val(v);
|
||||
p.find('form').submit();
|
||||
|
||||
setTimeout(function() {
|
||||
ok(!p.is(':visible'), 'popover closed');
|
||||
equal(req, 0, 'request was not performed');
|
||||
e.remove();
|
||||
start();
|
||||
}, timeout);
|
||||
});
|
||||
|
||||
asyncTest("cancelnochange: false", function () {
|
||||
var v = 'abc',
|
||||
e = $('<a href="#" data-type="text" data-pk="1" data-url="post-yes.php" data-name="text1">'+v+'</a>').appendTo(fx).editable({
|
||||
cancelnochange: false
|
||||
}),
|
||||
req = 0;
|
||||
|
||||
$.mockjax({
|
||||
url: 'post-yes.php',
|
||||
response: function() {
|
||||
req++;
|
||||
}
|
||||
});
|
||||
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
ok(p.is(':visible'), 'popover visible');
|
||||
p.find('input[type="text"]').val(v);
|
||||
p.find('form').submit();
|
||||
|
||||
setTimeout(function() {
|
||||
ok(!p.is(':visible'), 'popover closed');
|
||||
equal(req, 1, 'request was performed');
|
||||
e.remove();
|
||||
start();
|
||||
}, timeout);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
//unfortunatly, testing this feature does not always work in browsers. Tested manually.
|
||||
|
@ -149,30 +149,6 @@ $(function () {
|
||||
});
|
||||
*/
|
||||
|
||||
asyncTest("should not perform request if value not changed", function () {
|
||||
var e = $('<a href="#" data-pk="1" data-url="post-no.php" data-name="text1">abc</a>').appendTo(fx).editable(),
|
||||
req = 0;
|
||||
|
||||
$.mockjax({
|
||||
url: 'post-no.php',
|
||||
response: function() {
|
||||
req++;
|
||||
}
|
||||
});
|
||||
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
ok(p.is(':visible'), 'popover visible');
|
||||
p.find('button[type=submit]').click();
|
||||
|
||||
setTimeout(function() {
|
||||
ok(!p.is(':visible'), 'popover closed');
|
||||
equal(req, 0, 'request was not performed');
|
||||
e.remove();
|
||||
start();
|
||||
}, timeout);
|
||||
});
|
||||
|
||||
asyncTest("should show error if success callback returns string", function () {
|
||||
var newText = 'cd<e>;"',
|
||||
e = $('<a href="#" data-pk="1" data-url="post.php" data-name="text1">abc</a>').appendTo(fx).editable({
|
||||
|
Loading…
x
Reference in New Issue
Block a user