bebraw / colorjoe

Scaleable color picker with touch and AMD support (MIT)
http://bebraw.github.io/colorjoe/
MIT License
568 stars 68 forks source link

Enter hex number in HTML form #32

Closed simetin closed 8 years ago

simetin commented 8 years ago

Hi guys ! I have setup the colorpicker in an HTML form, but I'm facing an issue. When I try to enter manually the hex number and press enter, it submit the form.

Any idea for a solution ?

bebraw commented 8 years ago

@tchinou1 You might need to add event.preventDefault somewhere in the input logic. This might mean we need to tweak colorjoe itself as this is the sane way to do it.

See also http://stackoverflow.com/a/895231/228885 .

simetin commented 8 years ago

I've tried something like bellow, but it don't work. Have I made a mistake ?

$(document).ready(function() { $(window).keydown(function(event){ if($('.colorPicker').css('display') == 'inline-block'){ event.preventDefault(); return false; } }); });