首页 > 解决方案 > Jpicker rails:如何在rails中选择透明选项?

问题描述

我正在使用 Jpicker 选择背景颜色,并且没有选择透明的选项。我想添加一个函数,如果输入为空白,则将颜色设置为透明。我尝试将以下内容添加到初始化代码中,但它对我不起作用。

function (color, context) {
        var all = color.val('all');
            alert('Color chosen - hex: ' + (all && '#' + all.hex || 'none') + ' - alpha: ' + (all && all.a + '%' || 'none'));

        if (all.a != null)
        {
          var b =   Math.precision((all.a * 100) / 255, 0);
            alert(b);
        }

        $('#Commit').css(
                {
                    backgroundColor:all && '#' + all.hex || 'transparent'
                }); // prevent IE from throwing exception if hex is empty
    }

标签: ruby-on-railsjpicker

解决方案


推荐阅读