jQuery jedableマルチセレクトプラグインはありますか?
-
22-09-2019 - |
解決
私は、オプションの「選択された」オプションなしでは機能しなくなり、サイズの属性を非コードしていないKalyanの提案に小さなパッチを作成しました。それから、私はあなたがジェディタブルそれ自体に貼り付ける必要があるものではなく、ジェディタブルプラグインにそれを変更しました。私は現在、これを顧客のウェブサイトで使用していますが、JSON文字列のみを使用しているので、他の方法はまだバグがあるかもしれません。
$.editable.addInputType("multiselect", {
element: function (settings, original) {
var select = $('<select multiple="multiple" />');
if (settings.width != 'none') { select.width(settings.width); }
if (settings.size) { select.attr('size', settings.size); }
$(this).append(select);
return (select);
},
content: function (data, settings, original) {
/* If it is string assume it is json. */
if (String == data.constructor) {
eval('var json = ' + data);
} else {
/* Otherwise assume it is a hash already. */
var json = data;
}
for (var key in json) {
if (!json.hasOwnProperty(key)) {
continue;
}
if ('selected' == key) {
continue;
}
var option = $('<option />').val(key).append(json[key]);
$('select', this).append(option);
}
if ($(this).val() == json['selected'] ||
$(this).html() == $.trim(original.revert)) {
$(this).attr('selected', 'selected');
}
/* Loop option again to set selected. IE needed this... */
$('select', this).children().each(function () {
if (json.selected) {
var option = $(this);
$.each(json.selected, function (index, value) {
if (option.val() == value) {
option.attr('selected', 'selected');
}
});
} else {
if (original.revert.indexOf($(this).html()) != -1)
$(this).attr('selected', 'selected');
}
});
}
});
他のヒント
私も同じことを探していました。それを達成しようとしていますが、何もうまくいかないようです。
ちなみに、私はこれを見つけましたが、これも機能しないようです - http://pastebin.com/cbdndv5h
Jedableプラグインはこれを行います。例:
$('.editable').editable('http://www.example.com/save.php', {
data : " {'E':'Letter E','F':'Letter F','G':'Letter G', 'selected':'F'}",
type : 'select',
submit : 'OK'
});
所属していません StackOverflow