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

Bug: Buttons submit form

4 Answers 333 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 25 Aug 2016, 08:07 AM

Hi,

 

I am using the latest Kendo UI version (2016.2.714) and found a bug in the colorpicker.

The buttons (Apply and Cancel) are rendered as

<button class="k-button k-primary apply">Apply</button>
<button class="k-button cancel">Cancel</button>

(see kendo.colorpicker.js line 504 for details or check  the source on github)

When included in a form both of the buttons always cause the form to get submitted when they get clicked as this is the common behavior of a button tag. Both of them should have the type attribute set to "button" to prevent the form from getting submitted. The rendered buttons should look like this:

 

<button type="button" class="k-button k-primary apply">Apply</button>
<button  type="button" class="k-button cancel">Cancel</button>

 

Best regards

 

Thomas

4 Answers, 1 is accepted

Sort by
0
Accepted
Ianko
Telerik team
answered on 29 Aug 2016, 05:21 AM

Hello Thomas,

You are right that the ColorPicker's buttons have no type="button" attribute, but the popup that includes these buttons is rendered outside the form. Therefore, clicking the buttons does not submit it.

Here you are a dojo that demonstrates the described scenario: http://dojo.telerik.com/AsadIR

Regards,
Ianko
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Thomas
Top achievements
Rank 1
answered on 29 Aug 2016, 06:26 AM

Hi Ianko,

thanks for your reply. I see, you are right, the Color Picker is rendered outside the form. But as I started this thread the buttons in the Color Picker did indeed submit my form in my application and for some reason they do not now and I can't figure out what I have changed to make behave them correctly. It looks like there was in bug in my code that caused this false behavior, so sorry for the confusion.

However, is there any disadvantage in adding the type="button" attribute?

 

Best regards

 

Thomas

0
Ianko
Telerik team
answered on 29 Aug 2016, 06:38 AM

Hello Thomas,

As this is a dynamically rendered element HTML compliant requirements regarding attributes are not a must. Basically, the only advantage for not having this attribute that I can think of is prevention of unneeded code. However, having them also does not break any of the HTML rendered and I am not aware of any disadvantages for that. 

If you need these attributes set up, you can always use few lines of JavaScript code to put them in the button tags. Also, if you find any particular advantages from doing that you can always submit this as a feature request on UserVoice, so that the dev team can consider it for possible future improvement.

Regards,
Ianko
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Thomas
Top achievements
Rank 1
answered on 29 Aug 2016, 07:21 AM

Hi Ianko

 

thanks again for your help, the problem is gone now as it seemed to be a bug in my code that caused the ColorPicker buttons to submit the form.

However, the UserVoice is a great idea.

 

Best regards

 

Thomas

Tags
ColorPicker
Asked by
Thomas
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or