Yii2Developer
Yii2Developer

Reputation: 85

How to close colorpicker after onSubmit event?

Library Link

I am using above library but could not be able to find anywhere that how can I close it by selecting any color without actually clicking anywhere in the screen (They must be using blur).

$('#colorSelector'+dynamicID).ColorPicker({
    color: '#0000ff',
    onShow: function (colpkr) {
        $(colpkr).fadeIn(500);
        return false;
    },
    onHide: function (colpkr) {
        $(colpkr).fadeOut(500);
        return false;
    },
    onSubmit: function (hsb, hex, rgb) {
        $('#colorSelector'+dynamicID).css('backgroundColor', '#' + hex);
    }
});

I have tried using this $(selector).colorpicker('close') But it did not work but breaks everything.

Upvotes: 0

Views: 652

Answers (1)

Rohan Rao
Rohan Rao

Reputation: 2603

Try closing the colorpicker on submit button

$('#colorSelector'+dynamicID).ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
    $(colpkr).fadeIn(500);
    return false;
},
onHide: function (colpkr) {
    $(colpkr).fadeOut(500);
    return false;
},
onSubmit: function (hsb, hex, rgb) {
    $('#colorSelector'+dynamicID).css('backgroundColor', '#' + hex);
    $('#colorSelector').hide(); // closes the color picker on submit after selection of color
}
});

Upvotes: 1

Related Questions