name is not requred anymore fixes #9
This commit is contained in:
parent
bd64464a5d
commit
612ecc5e55
@ -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)
|
||||
|
@ -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') {
|
||||
|
@ -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();
|
||||
|
@ -3,7 +3,6 @@ $(function () {
|
||||
module("api", {
|
||||
setup: function(){
|
||||
fx = $('#async-fixture');
|
||||
delete $.fn.editable.defaults.name;
|
||||
$.support.transition = false;
|
||||
}
|
||||
});
|
||||
|
@ -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,
|
||||
|
@ -5,7 +5,6 @@ $(function () {
|
||||
module("date", {
|
||||
setup: function(){
|
||||
fx = $('#async-fixture');
|
||||
$.fn.editable.defaults.name = 'name1';
|
||||
dpg = $.fn.datepicker.DPGlobal;
|
||||
}
|
||||
});
|
||||
|
@ -5,7 +5,6 @@ $(function () {
|
||||
module("dateui", {
|
||||
setup: function(){
|
||||
fx = $('#async-fixture');
|
||||
$.fn.editable.defaults.name = 'name1';
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -3,7 +3,6 @@ $(function () {
|
||||
module("text", {
|
||||
setup: function() {
|
||||
fx = $('#async-fixture');
|
||||
$.fn.editable.defaults.name = 'name1';
|
||||
$.support.transition = false;
|
||||
}
|
||||
});
|
||||
|
@ -5,8 +5,8 @@ $(function () {
|
||||
|
||||
module("textarea", {
|
||||
setup: function(){
|
||||
fx = $('#async-fixture'),
|
||||
$.fn.editable.defaults.name = 'name1';
|
||||
fx = $('#async-fixture');
|
||||
$.support.transition = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user