diff --git a/CHANGELOG.txt b/CHANGELOG.txt index fdef278..fada710 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ X-editable changelog Version 1.4.2 wip ---------------------------- +[enh #132] combodate options can be defined via data-combodate json string (vitalets) [enh] source defined as function now has scope of element and can return string used as url (vitalets) [bug #99] select2 with Hierarchical Data (kev360) [bug #81] wysihtml5: fix inserting image (vitalets) diff --git a/src/inputs/combodate/combodate.js b/src/inputs/combodate/combodate.js index a68c3f4..e6b4863 100644 --- a/src/inputs/combodate/combodate.js +++ b/src/inputs/combodate/combodate.js @@ -48,6 +48,9 @@ $(function(){ this.options.viewformat = this.options.format; } + //try parse combodate config defined as json string in data-combodate + options.combodate = $.fn.editableutils.tryParseJson(options.combodate, true); + //overriding combodate config (as by default jQuery extend() is not recursive) this.options.combodate = $.extend({}, Constructor.defaults.combodate, options.combodate, { format: this.options.format, diff --git a/test/unit/combodate.js b/test/unit/combodate.js index 7e0f275..3d9d6a1 100644 --- a/test/unit/combodate.js +++ b/test/unit/combodate.js @@ -13,6 +13,20 @@ $(function () { } }); + test("combodate options can be defined in data-combodate param", function () { + var e = $('<a href="#" data-type="combodate" data-combodate="{minYear: 2000, maxYear: 2001}" data-pk="1" data-url="/combodate"></a>').appendTo('#qunit-fixture').editable({ + format: fd, + viewformat: vfd, + template: fd + }), + m = moment(vd, vfd); + + e.click(); + var p = tip(e); + equal(p.find('.year option').length, 3, 'years applied correct'); + }); + + asyncTest("container should contain combodate and save new value (date)", function () { var e = $('<a href="#" data-type="combodate" data-pk="1" data-url="/combodate">'+vd+'</a>').appendTo(fx).editable({