name is not requred anymore fixes #9
This commit is contained in:
@ -3,6 +3,7 @@ X-editable changelog
|
|||||||
|
|
||||||
Version 1.1.0 wip
|
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] '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] form template changed: added DIV.editable-input, DIV.editable.buttons and $.fn.editableform buttons (vitalets)
|
||||||
[enh] new input type: checklist (vitalets)
|
[enh] new input type: checklist (vitalets)
|
||||||
|
@ -29,12 +29,8 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//name must be defined
|
//name
|
||||||
this.options.name = this.options.name || this.$element.attr('id');
|
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
|
//create input of specified type. Input will be used for converting value, not in form
|
||||||
if(typeof $.fn.editableform.types[this.options.type] === 'function') {
|
if(typeof $.fn.editableform.types[this.options.type] === 'function') {
|
||||||
|
@ -93,17 +93,16 @@ List - abstract class for inputs that have source option loaded from js array or
|
|||||||
cache.callbacks = [];
|
cache.callbacks = [];
|
||||||
cache.err_callbacks = [];
|
cache.err_callbacks = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
//loading sourceData from server
|
//loading sourceData from server
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.options.source,
|
url: this.options.source,
|
||||||
type: 'get',
|
type: 'get',
|
||||||
cache: false,
|
cache: false,
|
||||||
data: {name: this.options.name},
|
data: this.options.name ? {name: this.options.name} : {},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: $.proxy(function (data) {
|
success: $.proxy(function (data) {
|
||||||
cache.loading = false;
|
cache.loading = false;
|
||||||
// this.options.source = data;
|
|
||||||
this.sourceData = this.makeArray(data);
|
this.sourceData = this.makeArray(data);
|
||||||
if($.isArray(this.sourceData)) {
|
if($.isArray(this.sourceData)) {
|
||||||
this.doPrepend();
|
this.doPrepend();
|
||||||
|
@ -3,7 +3,6 @@ $(function () {
|
|||||||
module("api", {
|
module("api", {
|
||||||
setup: function(){
|
setup: function(){
|
||||||
fx = $('#async-fixture');
|
fx = $('#async-fixture');
|
||||||
delete $.fn.editable.defaults.name;
|
|
||||||
$.support.transition = false;
|
$.support.transition = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -4,9 +4,6 @@ $(function () {
|
|||||||
setup: function(){
|
setup: function(){
|
||||||
sfx = $('#qunit-fixture'),
|
sfx = $('#qunit-fixture'),
|
||||||
fx = $('#async-fixture');
|
fx = $('#async-fixture');
|
||||||
$.fn.editable.defaults.name = 'name2';
|
|
||||||
//clear cache
|
|
||||||
$(document).removeData('groups.php-'+$.fn.editable.defaults.name);
|
|
||||||
$.support.transition = false;
|
$.support.transition = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -58,7 +55,7 @@ $(function () {
|
|||||||
}, timeout);
|
}, 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({
|
var e = $('<a href="#" data-type="checklist" data-value="2,3" data-url="post.php"></a>').appendTo(fx).editable({
|
||||||
pk: 1,
|
pk: 1,
|
||||||
source: groupsArr,
|
source: groupsArr,
|
||||||
|
@ -5,7 +5,6 @@ $(function () {
|
|||||||
module("date", {
|
module("date", {
|
||||||
setup: function(){
|
setup: function(){
|
||||||
fx = $('#async-fixture');
|
fx = $('#async-fixture');
|
||||||
$.fn.editable.defaults.name = 'name1';
|
|
||||||
dpg = $.fn.datepicker.DPGlobal;
|
dpg = $.fn.datepicker.DPGlobal;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,7 +5,6 @@ $(function () {
|
|||||||
module("dateui", {
|
module("dateui", {
|
||||||
setup: function(){
|
setup: function(){
|
||||||
fx = $('#async-fixture');
|
fx = $('#async-fixture');
|
||||||
$.fn.editable.defaults.name = 'name1';
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,9 +4,6 @@ $(function () {
|
|||||||
setup: function(){
|
setup: function(){
|
||||||
sfx = $('#qunit-fixture'),
|
sfx = $('#qunit-fixture'),
|
||||||
fx = $('#async-fixture');
|
fx = $('#async-fixture');
|
||||||
$.fn.editable.defaults.name = 'name1';
|
|
||||||
//clear cache
|
|
||||||
$(document).removeData('groups.php-'+$.fn.editable.defaults.name);
|
|
||||||
$.support.transition = false;
|
$.support.transition = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -167,7 +164,7 @@ $(function () {
|
|||||||
}, timeout);
|
}, 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({
|
var e = $('<a href="#" data-type="select" data-value="2" data-url="post.php">customer</a>').appendTo(fx).editable({
|
||||||
pk: 1,
|
pk: 1,
|
||||||
source: groups
|
source: groups
|
||||||
@ -192,8 +189,8 @@ $(function () {
|
|||||||
e.remove();
|
e.remove();
|
||||||
start();
|
start();
|
||||||
}, timeout);
|
}, timeout);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("if new text is empty --> show emptytext on save", function () {
|
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({
|
var e = $('<a href="#" data-type="select" data-value="2" data-url="post.php">customer</a>').appendTo(fx).editable({
|
||||||
pk: 1,
|
pk: 1,
|
||||||
@ -248,8 +245,11 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("cache request for same selects", 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(),
|
//clear cache
|
||||||
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(),
|
$(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;
|
req = 0;
|
||||||
|
|
||||||
$.mockjax({
|
$.mockjax({
|
||||||
@ -293,6 +293,10 @@ $(function () {
|
|||||||
|
|
||||||
asyncTest("cache simultaneous requests", function () {
|
asyncTest("cache simultaneous requests", function () {
|
||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
|
//clear cache
|
||||||
|
$(document).removeData('groups.php-name1');
|
||||||
|
|
||||||
var req = 0;
|
var req = 0;
|
||||||
$.mockjax({
|
$.mockjax({
|
||||||
url: 'groups-cache-sim.php',
|
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(),
|
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-value="2" 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-value="3" 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() {
|
setTimeout(function() {
|
||||||
|
|
||||||
@ -324,6 +328,10 @@ $(function () {
|
|||||||
|
|
||||||
asyncTest("cache simultaneous requests (loading error)", function () {
|
asyncTest("cache simultaneous requests (loading error)", function () {
|
||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
|
//clear cache
|
||||||
|
$(document).removeData('groups.php-name1');
|
||||||
|
|
||||||
var req = 0;
|
var req = 0;
|
||||||
$.mockjax({
|
$.mockjax({
|
||||||
url: 'groups-cache-sim-err.php',
|
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(),
|
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-value="2" 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-value="3" data-autotext="always" data-url="post.php" data-source="groups-cache-sim-err.php">6456</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;
|
errText = $.fn.editableform.types.select.defaults.sourceError;
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
@ -3,7 +3,6 @@ $(function () {
|
|||||||
module("text", {
|
module("text", {
|
||||||
setup: function() {
|
setup: function() {
|
||||||
fx = $('#async-fixture');
|
fx = $('#async-fixture');
|
||||||
$.fn.editable.defaults.name = 'name1';
|
|
||||||
$.support.transition = false;
|
$.support.transition = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,8 +5,8 @@ $(function () {
|
|||||||
|
|
||||||
module("textarea", {
|
module("textarea", {
|
||||||
setup: function(){
|
setup: function(){
|
||||||
fx = $('#async-fixture'),
|
fx = $('#async-fixture');
|
||||||
$.fn.editable.defaults.name = 'name1';
|
$.support.transition = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user