【问题标题】:Cancel in Spectrum Colorpicker Not Working在 Spectrum Colorpicker 中取消不工作
【发布时间】:2016-05-07 12:51:33
【问题描述】:

我使用spectrum.js颜色选择器仅取消事件不起作用,我必须将颜色重置为初始颜色,因为我得到previewElement null。如何解决这个问题。

【问题讨论】:

    标签: javascript jquery spectrumjs


    【解决方案1】:

    要取消对预览的更改,请使用 events,如下所示:

    var isChanged = false;
    $("#picker").spectrum({
        move : function (tinycolor) {
            // apply the changes to previewElement 
        },
        show : function (tinycolor) {
            isChanged = false;
            previousСolor = tinycolo
        },
        hide : function (tinycolor) {
            if (!isChanged && previousСolor) {
                // revert the changes in the previewElement 
            }
        },
        change : function (tinycolor) {
            isChanged = true;
            // apply the changes to previewElement 
        }
    });
    

    example

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-07
      • 1970-01-01
      • 2012-11-12
      相关资源
      最近更新 更多