bulma-extensions icon indicating copy to clipboard operation
bulma-extensions copied to clipboard

datetimepicker-clear-button in bulma-calendar submits a form

Open kstastny opened this issue 5 years ago • 4 comments

Hi,

I would like to use bulma-calendar in a form. However, when pressing the X (button with class datetimepicker-clear-button) to clear calendar value, the form is submitted and the application redirects me to localhost (on development machine).

Is there a way to stop submitting the form?

The only way I found to do it is modifying the calendar HTML and changing <button class="datetimepicker-clear-button"> to <button type="button" class="datetimepicker-clear-button"> but that means touching the component.

thank you

kstastny avatar Jul 10 '19 07:07 kstastny

+1

YoanaDimitrova1 avatar Sep 16 '19 10:09 YoanaDimitrova1

instead of customizing the code, you can disable the button after initialization

var clearbuttons = document.getElementsByClassName('datetimepicker-clear-button'); for(var i = 0; i< clearbuttons.length; i++) { clearbuttons[i].disabled = true; }

jcheng77 avatar Nov 06 '19 16:11 jcheng77

@jcheng77 Wouldn't the user be confused by the presence of a button that can't be used? Also, there will be no way of clearing out the date as the input field is disabled with Bulma (if I remember correctly).

YoanaDimitrova1 avatar Nov 06 '19 16:11 YoanaDimitrova1

My solution is to manipulate the DOM after calendar initialization like so:

$('.datetimepicker-clear-button').attr('type', 'button');

Achieves what the OP originally set out to do without touching the component source.

jcerar avatar Mar 16 '20 10:03 jcerar