oncebot / popbox.js

A tiny and simple stackable modal plugin for web apps
MIT License
296 stars 17 forks source link

Unable to toggle checkbox #4

Open premregmi opened 5 years ago

premregmi commented 5 years ago

This modal plugin is awesome but I am blocked with 1 issue. I can't toggle checkbox inside this popbox. If checked it can not be unchecked and if unchecked I can not make it checked.

<div class="popbox" data-popbox-id="manageGroupModalConfirm">
    <div class="popbox-content bg-white">
      <div class="modal-body">
        <input type="checkbox">
        <div class="custom-control custom-checkbox">
          <label class="custom-control-label" for="manageGroupDontShow">Don’t show this message again</label>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" data-popbox-close="manageGroupModalConfirm">Ok</button>
      </div>
    </div>
</div>
Naumov1889 commented 4 years ago

I didn't get deep into it but removing e.preventDefault() from the source code (look at the code fragment below) should solve the problem.

....
popboxs[i].addEventListener('click', function(e){
    e.preventDefault();   // <-- remove this line
...
Voltra commented 1 year ago

Technically they'd just have to check if e.currentTarget === popboxs[i] before calling preventDefault. Otherwise yeah, it basically nukes out of existence any click event inside the modal

Voltra commented 1 year ago

Checking e.defaultPrevented would be nice as well to have undesired click event processing