Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

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

Open
kstastny opened this issue Jul 10, 2019 · 4 comments
Open

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

kstastny opened this issue Jul 10, 2019 · 4 comments

Comments

@kstastny
Copy link

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

@YoanaDimitrova1
Copy link

+1

@jcheng77
Copy link

jcheng77 commented Nov 6, 2019

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;
}

@YoanaDimitrova1
Copy link

@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).

@jcerar
Copy link

jcerar commented Mar 16, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants