diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d9b3c8b..07824fc 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ X-editable changelog Version 1.1.0 wip ---------------------------- +[enh #9] 'name' or 'id' is not required anymore (vitalets) [enh] 'clear' button added in date and dateui (vitalets) [enh] form template changed: added DIV.editable-input, DIV.editable.buttons and $.fn.editableform buttons (vitalets) [enh] new input type: checklist (vitalets) diff --git a/src/element/editable-element.js b/src/element/editable-element.js index ed282fd..fe581cd 100644 --- a/src/element/editable-element.js +++ b/src/element/editable-element.js @@ -29,12 +29,8 @@ Makes editable any HTML element on the page. Applied as jQuery method. return; } - //name must be defined + //name this.options.name = this.options.name || this.$element.attr('id'); - if (!this.options.name) { - $.error('You must define name (or id) for Editable element'); - return; - } //create input of specified type. Input will be used for converting value, not in form if(typeof $.fn.editableform.types[this.options.type] === 'function') { diff --git a/src/inputs/list.js b/src/inputs/list.js index 33be516..fc8412c 100644 --- a/src/inputs/list.js +++ b/src/inputs/list.js @@ -93,17 +93,16 @@ List - abstract class for inputs that have source option loaded from js array or cache.callbacks = []; cache.err_callbacks = []; } - + //loading sourceData from server $.ajax({ url: this.options.source, type: 'get', cache: false, - data: {name: this.options.name}, + data: this.options.name ? {name: this.options.name} : {}, dataType: 'json', success: $.proxy(function (data) { cache.loading = false; - // this.options.source = data; this.sourceData = this.makeArray(data); if($.isArray(this.sourceData)) { this.doPrepend(); diff --git a/test/unit/api.js b/test/unit/api.js index dfb24fb..313e682 100644 --- a/test/unit/api.js +++ b/test/unit/api.js @@ -3,7 +3,6 @@ $(function () { module("api", { setup: function(){ fx = $('#async-fixture'); - delete $.fn.editable.defaults.name; $.support.transition = false; } }); diff --git a/test/unit/checklist.js b/test/unit/checklist.js index 1f4258f..294d2a5 100644 --- a/test/unit/checklist.js +++ b/test/unit/checklist.js @@ -4,9 +4,6 @@ $(function () { setup: function(){ sfx = $('#qunit-fixture'), fx = $('#async-fixture'); - $.fn.editable.defaults.name = 'name2'; - //clear cache - $(document).removeData('groups.php-'+$.fn.editable.defaults.name); $.support.transition = false; } }); @@ -58,7 +55,7 @@ $(function () { }, timeout); }); - asyncTest("test limit", function () { + asyncTest("limit option", function () { var e = $('<a href="#" data-type="checklist" data-value="2,3" data-url="post.php"></a>').appendTo(fx).editable({ pk: 1, source: groupsArr, diff --git a/test/unit/date.js b/test/unit/date.js index e2ab4cc..83f6707 100644 --- a/test/unit/date.js +++ b/test/unit/date.js @@ -5,7 +5,6 @@ $(function () { module("date", { setup: function(){ fx = $('#async-fixture'); - $.fn.editable.defaults.name = 'name1'; dpg = $.fn.datepicker.DPGlobal; } }); diff --git a/test/unit/dateui.js b/test/unit/dateui.js index 91c22fb..f6a1d20 100644 --- a/test/unit/dateui.js +++ b/test/unit/dateui.js @@ -5,7 +5,6 @@ $(function () { module("dateui", { setup: function(){ fx = $('#async-fixture'); - $.fn.editable.defaults.name = 'name1'; } }); diff --git a/test/unit/select.js b/test/unit/select.js index fec4a8e..b4b969f 100644 --- a/test/unit/select.js +++ b/test/unit/select.js @@ -4,9 +4,6 @@ $(function () { setup: function(){ sfx = $('#qunit-fixture'), fx = $('#async-fixture'); - $.fn.editable.defaults.name = 'name1'; - //clear cache - $(document).removeData('groups.php-'+$.fn.editable.defaults.name); $.support.transition = false; } }); @@ -167,7 +164,7 @@ $(function () { }, timeout); }) - asyncTest("popover should save new selected value", function () { + asyncTest("should save new selected value", function () { var e = $('<a href="#" data-type="select" data-value="2" data-url="post.php">customer</a>').appendTo(fx).editable({ pk: 1, source: groups @@ -192,8 +189,8 @@ $(function () { e.remove(); start(); }, timeout); - }); - + }); + asyncTest("if new text is empty --> show emptytext on save", function () { var e = $('<a href="#" data-type="select" data-value="2" data-url="post.php">customer</a>').appendTo(fx).editable({ pk: 1, @@ -248,8 +245,11 @@ $(function () { }); asyncTest("cache request for same selects", function () { - var e = $('<a href="#" data-type="select" data-pk="1" data-value="2" data-url="post.php" data-source="groups-cache.php">customer</a>').appendTo(fx).editable(), - e1 = $('<a href="#" data-type="select" data-pk="1" data-value="2" data-url="post.php" data-source="groups-cache.php">customer</a>').appendTo(fx).editable(), + //clear cache + $(document).removeData('groups.php-name1'); + + var e = $('<a href="#" data-type="select" data-pk="1" data-name="name1" data-value="2" data-url="post.php" data-source="groups-cache.php">customer</a>').appendTo(fx).editable(), + e1 = $('<a href="#" data-type="select" data-pk="1" id="name1" data-value="2" data-url="post.php" data-source="groups-cache.php">customer</a>').appendTo(fx).editable(), req = 0; $.mockjax({ @@ -293,6 +293,10 @@ $(function () { asyncTest("cache simultaneous requests", function () { expect(4); + + //clear cache + $(document).removeData('groups.php-name1'); + var req = 0; $.mockjax({ url: 'groups-cache-sim.php', @@ -303,9 +307,9 @@ $(function () { } }); - var e = $('<a href="#" data-type="select" data-pk="1" data-value="1" data-url="post.php" data-source="groups-cache-sim.php"></a>').appendTo(fx).editable(), - e1 = $('<a href="#" data-type="select" data-pk="1" data-value="2" data-url="post.php" data-source="groups-cache-sim.php"></a>').appendTo(fx).editable(), - e2 = $('<a href="#" data-type="select" data-pk="1" data-value="3" data-url="post.php" data-source="groups-cache-sim.php"></a>').appendTo(fx).editable(); + var e = $('<a href="#" data-type="select" data-pk="1" data-name="name1" data-value="1" data-url="post.php" data-source="groups-cache-sim.php"></a>').appendTo(fx).editable(), + e1 = $('<a href="#" data-type="select" data-pk="1" data-name="name1" data-value="2" data-url="post.php" data-source="groups-cache-sim.php"></a>').appendTo(fx).editable(), + e2 = $('<a href="#" data-type="select" data-pk="1" data-name="name1" data-value="3" data-url="post.php" data-source="groups-cache-sim.php"></a>').appendTo(fx).editable(); setTimeout(function() { @@ -324,6 +328,10 @@ $(function () { asyncTest("cache simultaneous requests (loading error)", function () { expect(4); + + //clear cache + $(document).removeData('groups.php-name1'); + var req = 0; $.mockjax({ url: 'groups-cache-sim-err.php', @@ -334,9 +342,9 @@ $(function () { } }); - var e = $('<a href="#" data-type="select" data-pk="1" data-value="1" data-autotext="always" data-url="post.php" data-source="groups-cache-sim-err.php">35</a>').appendTo(fx).editable(), - e1 = $('<a href="#" data-type="select" data-pk="1" data-value="2" data-autotext="always" data-url="post.php" data-source="groups-cache-sim-err.php">35</a>').appendTo(fx).editable(), - e2 = $('<a href="#" data-type="select" data-pk="1" data-value="3" data-autotext="always" data-url="post.php" data-source="groups-cache-sim-err.php">6456</a>').appendTo(fx).editable(), + var e = $('<a href="#" data-type="select" data-pk="1" data-name="name1" data-value="1" data-autotext="always" data-url="post.php" data-source="groups-cache-sim-err.php">35</a>').appendTo(fx).editable(), + e1 = $('<a href="#" data-type="select" data-pk="1" data-name="name1" data-value="2" data-autotext="always" data-url="post.php" data-source="groups-cache-sim-err.php">35</a>').appendTo(fx).editable(), + e2 = $('<a href="#" data-type="select" data-pk="1" data-name="name1" data-value="3" data-autotext="always" data-url="post.php" data-source="groups-cache-sim-err.php">6456</a>').appendTo(fx).editable(), errText = $.fn.editableform.types.select.defaults.sourceError; setTimeout(function() { diff --git a/test/unit/text.js b/test/unit/text.js index df70bda..79f1b90 100644 --- a/test/unit/text.js +++ b/test/unit/text.js @@ -3,7 +3,6 @@ $(function () { module("text", { setup: function() { fx = $('#async-fixture'); - $.fn.editable.defaults.name = 'name1'; $.support.transition = false; } }); diff --git a/test/unit/textarea.js b/test/unit/textarea.js index cee65bc..6a76813 100644 --- a/test/unit/textarea.js +++ b/test/unit/textarea.js @@ -5,8 +5,8 @@ $(function () { module("textarea", { setup: function(){ - fx = $('#async-fixture'), - $.fn.editable.defaults.name = 'name1'; + fx = $('#async-fixture'); + $.support.transition = false; } });