clear date & datetime when showbuttons=false, fix

This commit is contained in:
vitalets
2013-04-02 21:32:29 +04:00
parent ca14bed8e3
commit 21a6148f8d
5 changed files with 96 additions and 3 deletions

@ -148,7 +148,7 @@ $(function () {
ok(!p.is(':visible'), 'popover closed');
});
asyncTest("clear button", function () {
asyncTest("clear button (showbuttons: true)", function () {
var d = '15.05.1984',
e = $('<a href="#" data-type="date" data-pk="1" data-url="post-date-clear.php">'+d+'</a>').appendTo(fx).editable({
format: f,
@ -189,5 +189,46 @@ $(function () {
}, timeout);
});
asyncTest("clear button (showbuttons: false)", function () {
var d = '15.05.1984',
e = $('<a href="#" data-type="date" data-pk="1" data-url="post-date-clear1.php">'+d+'</a>').appendTo(fx).editable({
format: f,
clear: 'abc',
showbuttons: false
});
$.mockjax({
url: 'post-date-clear1.php',
response: function(settings) {
equal(settings.data.value, '', 'submitted value correct');
}
});
equal(frmt(e.data('editable').value, 'dd.mm.yyyy'), d, 'value correct');
e.click();
var p = tip(e);
ok(p.find('.datepicker').is(':visible'), 'datepicker exists');
equal(frmt(e.data('editable').value, f), d, 'day set correct');
equal(p.find('td.day.active').text(), 15, 'day shown correct');
var clear = p.find('.editable-clear a');
equal(clear.text(), 'abc', 'clear link shown');
//click clear
clear.click();
setTimeout(function() {
ok(!p.is(':visible'), 'popover closed');
equal(e.data('editable').value, null, 'null saved to value');
equal(e.text(), e.data('editable').options.emptytext, 'empty text shown');
e.remove();
start();
}, timeout);
});
});