English 中文(简体)
是否存在着一种可笑的多偏偏多彩的 p?
原标题:Is there a jQuery jEditable Multi-select plugin?
  • 时间:2009-10-20 22:55:04
  •  标签:
最佳回答

我向卡利扬建议说,它没有选择的“选择”选择,就不去工作,没有硬性规定规模归属。 然后,我修改了它,把它变成了一种可笑的花.,而不是你不得不把自己 past为 j。 我目前正在一个客户网站使用这个字眼,尽管我使用这个词完全是用一只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 );
            }
        });
    }
});
问题回答

The jeditable plugin do this. Example:

$( .editable ).editable( http://www.example.com/save.php , { 
 data   : " { E : Letter E , F : Letter F , G : Letter G ,  selected : F }",
 type   :  select ,
 submit :  OK 
});




相关问题
热门标签