Wikiki/bulma-switch

Does it require javascript to work?

Closed this issue · 4 comments

First off thanks for the awesome work with the extensions!!

I just tried the switch in my project and the checkbox just remains as it was (i.e. it makes no difference to the state of the checkbox when I click on it).

I saw that you're using "id" on the form field. Does that mean it requires javascript for it to work?

If you could please advise.

Thanks!
Saurabh

Below in action:

manual-adjustment-brings-hazard-sign

Hi @sausin,

This extension is pure CSS. No JavaScript needed.

Please just respect the following strucure:

<div class="field">
  <input id="switchExample" type="checkbox" name="switchExample" class="switch" checked="checked">
  <label for="switchExample">Switch example</label>
</div>

the for attribute on label is mandatory.
It will link the label to the checkbox and then manage the style. This attribute need to be set up with the id attribute of the input (in my example switchExample).
Browsers manage natively the link between label ad input when using id and for attributes. So this is what I use in my extension to handle the user click.

Let me know if it's ok.

Regards

@Wikiki Thanks! Including the id and for makes it work properly!!

Once again, thanks a lot for your work on these extensions!

Thank you.

For information I have updated the documentation to give information about id and for attributes.

Regards