params can be a func, fixes

This commit is contained in:
vitalets
2012-11-21 14:51:13 +04:00
parent d9e818d287
commit 6a8cb83cbd
4 changed files with 56 additions and 9 deletions

@ -37,6 +37,7 @@ $(function () {
$.fn.editable.defaults.name = 'name1';
//clear cache
$(document).removeData('groups.php-'+$.fn.editable.defaults.name);
$.support.transition = false;
}
});

@ -4,6 +4,7 @@ $(function () {
setup: function() {
fx = $('#async-fixture');
$.fn.editable.defaults.name = 'name1';
$.support.transition = false;
}
});
@ -242,6 +243,38 @@ $(function () {
});
asyncTest("params as function", function () {
var e = $('<a href="#" data-pk="1" data-url="post-resp.php">abc</a>').appendTo(fx).editable({
name: 'username',
params: function(params) {
equal(params.pk, 1, 'params in func already have values (pk)');
return { q: 2, pk: 3 };
},
success: function(resp) {
equal(resp.dataType, 'json', 'dataType ok');
equal(resp.data.pk, 3, 'pk ok');
equal(resp.data.name, 'username', 'name ok');
equal(resp.data.value, newText, 'value ok');
equal(resp.data.q, 2, 'additional params ok');
}
}),
newText = 'cd<e>;"'
e.click()
var p = tip(e);
ok(p.find('input[type=text]').length, 'input exists')
p.find('input').val(newText);
p.find('form').submit();
setTimeout(function() {
e.remove();
start();
}, timeout);
});
asyncTest("submit to url defined as function", function () {
expect(3);
var newText = 'qwe',