This is a migrated thread and some comments may be shown as answers.

Fire event without change

1 Answer 106 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Ethan
Top achievements
Rank 1
Ethan asked on 09 Jul 2014, 05:18 PM
I'm trying to fire an event without change happening and I'm having some trouble figuring it out.

I have the Kendo UI widget on my webpage and the default value is #000000 when the color picker loads. If I click the Apply button in the color picker the 'change' event doesn't fire because I didn't change anything. If I change the slider and click 'Apply' then the value changes and is also put into the 'input text' field.
How do I get it so the value #000000 is set when I click Apply without changing anything?

Code snippet:
<input type="text" class="text colorPicker" size="25" maxlength="100" title="${geo:loc attribute=&quot;title&quot; phrase=&quot;Please enter the hexadecimal value for the font color.&quot; /}" name="${geo:object name='CntwChooseColorScheme.PRIMHEAD_FONTCOLOR' attribute='name'/}" id="${geo:object name='CntwChooseColorScheme.PRIMHEAD_FONTCOLOR' attribute='id'/}" value="${geo:object name='DERIVED_COMPONENT.Wizard.GetValue(CntwChooseColorScheme.PRIMHEAD_FONTCOLOR)' attribute='value'/}" /> <input id="primaryheaderfontcolor" type="color" value="${geo:object name='DERIVED_COMPONENT.Wizard.GetValue(CntwChooseColorScheme.PRIMHEAD_FONTCOLOR)' attribute='value'/}" /> <script> $("#primaryheaderfontcolor").kendoColorPicker({ value: "#000000", buttons: true, change: function(e) { $('#prim_head_font_color').val(e.value); console.log("The picked color is ", e.value); console.log(e); } }); </script>

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 11 Jul 2014, 08:22 AM
Hello Ethan,

I am not really sure that I understand exactly what your questions is, so please accept my apologies. In general when you set the value property of the widget the color is applied and shown. The change event is fired only when there is a difference between the already selected value and the one that is currently selected. Please see the following example and let me know what I missed:

http://jsbin.com/qekeg/1/edit

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
ColorPicker
Asked by
Ethan
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or