-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
mount and unmount iro.ColorPicker #73
Comments
Create a color picker: var colorPicker = new iro.ColorPicker({
...
}) Unmount from current DOM: colorPicker.el.removeChild(colorPicker.base);
colorPicker.el = null; Mount to new DOM: newElement.addChild(colorPicker.base);
colorPicler.el = newElement; |
Does the code works with API? |
Are you using the latest version of iro.js? ( Otherwise you may need to change |
I use this CDN link: https://cdn.jsdelivr.net/npm/@jaames/iro/dist/iro.min.js |
Looks like you're using the latest version then. I'm not sure why you're getting that error, without seeing your code I can only make guesses. |
html<title>repl.it</title> <script src="https://cdn.jsdelivr.net/npm/@jaames/iro/dist/iro.min.js"></script> <script src="script.js"></script> -------------- script.js ----------- var colorPicker = new iro.ColorPicker('div', { width: 200 });colorPicker.el.removeChild(colorPicker.base); |
You need a HTML element for the color picker to mount to first: <html>
<head>
<title>repl.it</title>
<script src="https://cdn.jsdelivr.net/npm/@jaames/iro/dist/iro.min.js"></script>
</head>
<body>
<!-- color picker element -->
<div class="colorPicker"></div>
<script>
var colorPicker = new iro.ColorPicker('.colorPicker', { width: 200 });
// ... and so on
</script>
</body>
</html> I'd recommend looking at the codepen demo https://codepen.io/rakujira/pen/WZOeNq?editors=1010 :) |
I tried both ways, but still same error. I will keep testing. And the link you sent, it refers to the original color picker page you have on codepen, right? |
Here, I have recreated the error: https://codepen.io/artmelkon/pen/wbVMZz?editors=1010 |
Ohh, I think you need to wait for the colorPicker's var colorPicker = new iro.ColorPicker('#color-picker', { width: 200 });
colorPicker.on('mount', function() {
colorPicker.el.removeChild(colorPicker.base);
colorPicker.el = null;
console.log(colorPicker.el)
}) When the color picker is created, the HTML DOM isn't necessarily ready yet :) Documentation: https://iro.js.org/colorPicker_api.html#events |
Ahh, it did work , thank you. |
No worries! |
can you please tell what children: Array[] is for? |
In what context? That doesn't sound like something from iro.js |
Sorry, couldn't find it anymore. I was running a script and it appeared in the console, but now I don't see it. |
Can you please show how to mount or unmount the color picker.
Thanks in advanced.
The text was updated successfully, but these errors were encountered: