New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saving Selected Color in input #123
Comments
You can shorten you code by using template strings: let $save_color = ($color, {_representation}) => {
let $value = $color.toHEXA().toString();
if (!window.wponion._.isUndefined(_representation)) {
$value = $color[`to${_representation}`].toString();
}
this.element.find('input.wponion-color-picker-element').val($value);
};
$instance.on('save', $save_color);
$instance.on('change', $save_color);
$instance.on('swatchselect', $save_color); I basically don't want to "polyfill" any native HTML5 input element, but I can add a let $save_color = (color, pickr) => {
this.element.find('input.wponion-color-picker-element')
.val($value[`to${pickr.getCurrentRepresetation()}`].toString(0));
};
$instance.on('change', $save_color);
$instance.on('swatchselect', $save_color);
$instance.on('change', (color, pickr) => {
this.element.find('input.wponion-color-picker-element')
.val($value[`to${pickr.getCurrentRepresetation()}`].toString(0));
}); |
@simonwep you proved it again you are a super human 😄 |
Oh lol, there is already |
lol sorry my bad. i think i am out of energy today !!!! |
Haha no problem, If it isn't mentioned anywhere it does basically not exist :D |
I've released |
@simonwep sorry to bother you again Error : https://vsp.ams3.cdn.digitaloceanspaces.com/sshots/i/2019/Jul/17/1563371916-177.gif Code
|
It's $instance.on('change', (color, pickr) => {
this.element.find('input.wponion-color-picker-element')
.val($value[`to${pickr.getColorRepresentation()}`].toString(0));
}); |
The zero in |
cool thanks for your faster reply and is it |
Whoops yeah it's color. The dollar sign confuses me: $instance.on('change', (color, pickr) => {
this.element.find('input.wponion-color-picker-element')
.val(color[`to${pickr.getColorRepresentation()}`].toString(0));
}); |
@simonwep nope your code is not working i get the below value
|
Also Note : |
If you haven't set |
And I forgot you only resolve the name with the template string, It's a function so you need to call it. $instance.on('change', (color, pickr) => {
this.element.find('input.wponion-color-picker-element')
.val(color[`to${pickr.getColorRepresentation()}`]().toString(0));
}); At the end there is |
@simonwep thanks :-) |
I'm closing it for now, since |
@simonwep Hi. I spent couple hours for understand that for |
@sergeizhukov Whoops typo in the README. You only got the instance as argument. I've updated the README, thx :) |
Hi Again,!!
i used this library in my framework and found that it dose not support
input[type=text]
element.so i created a
div
and was able to get it working.and then i found i can't even link
input
field to this library so it can update the selected color.so for that i created a small workaround as below
So i would like to know if there is a chance that you could support
input
field or even provide a custom argument where i can link myinput
field to get the values updated.The text was updated successfully, but these errors were encountered: