success moved to editableform

This commit is contained in:
vitalets
2012-11-22 18:14:57 +04:00
parent c3b53ec070
commit e79118f0cf
8 changed files with 118 additions and 51 deletions

@ -179,8 +179,8 @@ $(function () {
});
asyncTest("events: shown / cancel", function () {
expect(2);
asyncTest("events: shown / cancel / hidden", function () {
expect(3);
var val = '1',
e = $('<a href="#" data-pk="1" data-type="select" data-url="post.php" data-name="text" data-value="'+val+'"></a>').appendTo(fx);
@ -192,7 +192,12 @@ $(function () {
e.on('cancel', function(event) {
var editable = $(this).data('editable');
ok(true, 'cancel triggered');
});
});
e.on('hidden', function(event) {
var editable = $(this).data('editable');
ok(true, 'hidden triggered');
});
e.editable({
source: 'groups.php',
@ -209,7 +214,38 @@ $(function () {
}, timeout);
}, timeout);
});
});
asyncTest("event: save / hidden", function () {
expect(2);
var val = '1',
e = $('<a href="#" data-pk="1" data-type="select" data-url="post.php" data-name="text" data-value="'+val+'"></a>').appendTo(fx);
e.on('save', function(event, params) {
var editable = $(this).data('editable');
equal(params.newValue, 2, 'save triggered, value correct');
});
e.on('hidden', function(event) {
var editable = $(this).data('editable');
ok(true, 'hidden triggered');
});
e.editable({
source: 'groups.php',
});
e.click();
var p = tip(e);
p.find('select').val(2);
p.find('form').submit();
setTimeout(function() {
p.find('button[type=button]').click();
e.remove();
start();
}, timeout);
});
test("show/hide/toggle methods", function () {
@ -375,7 +411,7 @@ $(function () {
});
test("setValue", function () {
test("setValue method", function () {
var e = $('<a href="#" data-name="name" data-type="select" data-url="post.php"></a>').appendTo('#qunit-fixture').editable({
value: 1,
source: groups

@ -107,7 +107,7 @@
ok(!p2.is(':visible'), 'popover2 closed');
});
test("click outside popoover should hide it", function () {
test("click outside container should hide it", function () {
var e = $('<a href="#" data-pk="1" data-url="post.php" data-name="text1">abc</a>').appendTo('#qunit-fixture').editable(),
e1 = $('<div>').appendTo('body');

@ -186,13 +186,14 @@ $(function () {
}, timeout);
});
asyncTest("should show error if success callback return string", function () {
var e = $('<a href="#" data-pk="1" data-url="post.php" data-name="text1">abc</a>').appendTo(fx).editable({
success: function(data) {
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({
success: function(response, newValue) {
equal(newValue, newText, 'value in success passed correctly');
return 'error';
}
}),
newText = 'cd<e>;"'
});
e.click()
var p = tip(e);
@ -211,7 +212,7 @@ $(function () {
start();
}, timeout);
})
});
asyncTest("should submit all required params", function () {
var e = $('<a href="#" data-pk="1" data-url="post-resp.php">abc</a>').appendTo(fx).editable({