diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 39b256e..bc028fb 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,7 +4,9 @@ X-editable changelog Version 1.1.2 wip ---------------------------- -[bug #34] inputclass span* broken with fluid layout. Changed to input-*. (vitalets) +[enh] composite pk can be defined as JSON in data-pk attribute (vitalets) +[enh #30] new option 'sourceCache' true|false to disable cache for select (vitalets) +[bug #34] inputclass span* broken with fluid bootstrap layout. Classes changed to 'input-*'. (vitalets) [enh] utils now added to $.fn.editableutils instead of $.fn.editableform.utils (vitalets) [enh] input types now added to $.fn.editabletypes instead of $.fn.editableform.types (vitalets) [enh] playground and tests now use requirejs (vitalets) diff --git a/src/editable-form/editable-form.js b/src/editable-form/editable-form.js index 0a4369a..4cce879 100644 --- a/src/editable-form/editable-form.js +++ b/src/editable-form/editable-form.js @@ -227,6 +227,9 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'. }, save: function(value) { + //try parse composite pk defined as json string in data-pk + this.options.pk = $.fn.editableutils.tryParseJson(this.options.pk, true); + var pk = (typeof this.options.pk === 'function') ? this.options.pk.call(this) : this.options.pk, send = !!(typeof this.options.url === 'function' || (this.options.url && ((this.options.send === 'always') || (this.options.send === 'auto' && pk)))), params, ajaxOptions; diff --git a/test/unit/common.js b/test/unit/common.js index f0a0471..cc614f6 100644 --- a/test/unit/common.js +++ b/test/unit/common.js @@ -362,6 +362,35 @@ ok(!p.find('.editable-buttons').length, '.editable-buttons block not rendered'); }); + asyncTest("composite pk defined as json in data-pk attribute", function () { + var e = $('<a href="#" data-pk="{a: 1, b: 2}" data-url="post-pk.php">abc</a>').appendTo(fx).editable({ + name: 'username' + }), + newText = 'cd<e>;"' + + $.mockjax({ + url: 'post-pk.php', + response: function(settings) { + equal(settings.data.pk.a, 1, 'first part ok'); + equal(settings.data.pk.b, 2, 'second part ok'); + } + }); + + 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); + + }); + + //unfortunatly, testing this feature does not always work in browsers. Tested manually. /* test("enablefocus option", function () {