Bootstrap 4 - Checkbox not Working Properly inside Popover in Bootstrap Modal












1















There are two checkboxes inside popover in Bootstrap Modal. The fiddle is here.



HTML:



<div class="container-fluid">
<div class="row">
<div class="col-12">
<button type="button" class="btn btn-primary open-modal" data-toggle="modal" data-target="#bs-modal">
Open Modal
</button>
<div class="modal fade" id="bs-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Bootstrap 4 Modal</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<button type="button" class="btn btn-secondary btn-sm bs-popover" data-container="body" data-toggle="popover">
Show Popover
</button>
<div id="popover-content">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="1"
id="default-checkbox" name="default-checkbox">
<label class="form-check-label" for="default-checkbox">
Default Checkbox
</label>
</div>
<br>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="custom-checkbox" name="custom-checkbox" value="2">
<label class="custom-control-label" for="custom-checkbox">Custom Checkbox</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>


CSS:



.open-modal {
margin: 20px;
}
.modal-body {
min-height: 200px;
}
#popover-content {
display: none;
}


JS:



$('.bs-popover').popover({
html: true,
content: function() {
return $('#popover-content').html();
},
title: 'Popover Title'
});


1. Problem with Default Checkbox: I'm not able to check it by clicking the label.



2. Problem with Custom Checkbox: It cannot be checked.



Why is this happening? How can I fix it? Any help would be appreciated.










share|improve this question





























    1















    There are two checkboxes inside popover in Bootstrap Modal. The fiddle is here.



    HTML:



    <div class="container-fluid">
    <div class="row">
    <div class="col-12">
    <button type="button" class="btn btn-primary open-modal" data-toggle="modal" data-target="#bs-modal">
    Open Modal
    </button>
    <div class="modal fade" id="bs-modal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
    <div class="modal-header">
    <h5 class="modal-title" id="exampleModalLabel">Bootstrap 4 Modal</h5>
    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
    <span aria-hidden="true">&times;</span>
    </button>
    </div>
    <div class="modal-body">
    <button type="button" class="btn btn-secondary btn-sm bs-popover" data-container="body" data-toggle="popover">
    Show Popover
    </button>
    <div id="popover-content">
    <div class="form-check">
    <input class="form-check-input" type="checkbox" value="1"
    id="default-checkbox" name="default-checkbox">
    <label class="form-check-label" for="default-checkbox">
    Default Checkbox
    </label>
    </div>
    <br>
    <div class="custom-control custom-checkbox">
    <input type="checkbox" class="custom-control-input" id="custom-checkbox" name="custom-checkbox" value="2">
    <label class="custom-control-label" for="custom-checkbox">Custom Checkbox</label>
    </div>
    </div>
    </div>
    <div class="modal-footer">
    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
    <button type="button" class="btn btn-primary">Save changes</button>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>


    CSS:



    .open-modal {
    margin: 20px;
    }
    .modal-body {
    min-height: 200px;
    }
    #popover-content {
    display: none;
    }


    JS:



    $('.bs-popover').popover({
    html: true,
    content: function() {
    return $('#popover-content').html();
    },
    title: 'Popover Title'
    });


    1. Problem with Default Checkbox: I'm not able to check it by clicking the label.



    2. Problem with Custom Checkbox: It cannot be checked.



    Why is this happening? How can I fix it? Any help would be appreciated.










    share|improve this question



























      1












      1








      1


      1






      There are two checkboxes inside popover in Bootstrap Modal. The fiddle is here.



      HTML:



      <div class="container-fluid">
      <div class="row">
      <div class="col-12">
      <button type="button" class="btn btn-primary open-modal" data-toggle="modal" data-target="#bs-modal">
      Open Modal
      </button>
      <div class="modal fade" id="bs-modal" tabindex="-1" role="dialog" aria-hidden="true">
      <div class="modal-dialog modal-lg" role="document">
      <div class="modal-content">
      <div class="modal-header">
      <h5 class="modal-title" id="exampleModalLabel">Bootstrap 4 Modal</h5>
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
      <span aria-hidden="true">&times;</span>
      </button>
      </div>
      <div class="modal-body">
      <button type="button" class="btn btn-secondary btn-sm bs-popover" data-container="body" data-toggle="popover">
      Show Popover
      </button>
      <div id="popover-content">
      <div class="form-check">
      <input class="form-check-input" type="checkbox" value="1"
      id="default-checkbox" name="default-checkbox">
      <label class="form-check-label" for="default-checkbox">
      Default Checkbox
      </label>
      </div>
      <br>
      <div class="custom-control custom-checkbox">
      <input type="checkbox" class="custom-control-input" id="custom-checkbox" name="custom-checkbox" value="2">
      <label class="custom-control-label" for="custom-checkbox">Custom Checkbox</label>
      </div>
      </div>
      </div>
      <div class="modal-footer">
      <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      <button type="button" class="btn btn-primary">Save changes</button>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>


      CSS:



      .open-modal {
      margin: 20px;
      }
      .modal-body {
      min-height: 200px;
      }
      #popover-content {
      display: none;
      }


      JS:



      $('.bs-popover').popover({
      html: true,
      content: function() {
      return $('#popover-content').html();
      },
      title: 'Popover Title'
      });


      1. Problem with Default Checkbox: I'm not able to check it by clicking the label.



      2. Problem with Custom Checkbox: It cannot be checked.



      Why is this happening? How can I fix it? Any help would be appreciated.










      share|improve this question
















      There are two checkboxes inside popover in Bootstrap Modal. The fiddle is here.



      HTML:



      <div class="container-fluid">
      <div class="row">
      <div class="col-12">
      <button type="button" class="btn btn-primary open-modal" data-toggle="modal" data-target="#bs-modal">
      Open Modal
      </button>
      <div class="modal fade" id="bs-modal" tabindex="-1" role="dialog" aria-hidden="true">
      <div class="modal-dialog modal-lg" role="document">
      <div class="modal-content">
      <div class="modal-header">
      <h5 class="modal-title" id="exampleModalLabel">Bootstrap 4 Modal</h5>
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
      <span aria-hidden="true">&times;</span>
      </button>
      </div>
      <div class="modal-body">
      <button type="button" class="btn btn-secondary btn-sm bs-popover" data-container="body" data-toggle="popover">
      Show Popover
      </button>
      <div id="popover-content">
      <div class="form-check">
      <input class="form-check-input" type="checkbox" value="1"
      id="default-checkbox" name="default-checkbox">
      <label class="form-check-label" for="default-checkbox">
      Default Checkbox
      </label>
      </div>
      <br>
      <div class="custom-control custom-checkbox">
      <input type="checkbox" class="custom-control-input" id="custom-checkbox" name="custom-checkbox" value="2">
      <label class="custom-control-label" for="custom-checkbox">Custom Checkbox</label>
      </div>
      </div>
      </div>
      <div class="modal-footer">
      <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      <button type="button" class="btn btn-primary">Save changes</button>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>


      CSS:



      .open-modal {
      margin: 20px;
      }
      .modal-body {
      min-height: 200px;
      }
      #popover-content {
      display: none;
      }


      JS:



      $('.bs-popover').popover({
      html: true,
      content: function() {
      return $('#popover-content').html();
      },
      title: 'Popover Title'
      });


      1. Problem with Default Checkbox: I'm not able to check it by clicking the label.



      2. Problem with Custom Checkbox: It cannot be checked.



      Why is this happening? How can I fix it? Any help would be appreciated.







      jquery twitter-bootstrap checkbox bootstrap-4 bootstrap-modal






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '18 at 0:50







      N'Bayramberdiyev

















      asked Nov 24 '18 at 0:20









      N'BayramberdiyevN'Bayramberdiyev

      1036




      1036
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Wrap the checkbox within a label tag:



          <div class="form-check">
          <label class="form-check-label">
          <input class="form-check-input" type="checkbox" value="1">
          Default checkbox
          </label>
          </div>


          and change your custom checkbox to :



          <div class="form-group">
          <label class="custom-control custom-checkbox">
          <input type="checkbox" value="2" name="chbxTerms" class="custom-control-input">
          <span class="custom-control-label" for="chbxTerms">Custom checkbox</span>
          </label>
          </div>


          working plunker: http://plnkr.co/edit/yy4sshzCnSmuso0XocOX?p=preview






          share|improve this answer



















          • 1





            It worked. Thank you.

            – N'Bayramberdiyev
            Nov 25 '18 at 12:40











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454146%2fbootstrap-4-checkbox-not-working-properly-inside-popover-in-bootstrap-modal%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Wrap the checkbox within a label tag:



          <div class="form-check">
          <label class="form-check-label">
          <input class="form-check-input" type="checkbox" value="1">
          Default checkbox
          </label>
          </div>


          and change your custom checkbox to :



          <div class="form-group">
          <label class="custom-control custom-checkbox">
          <input type="checkbox" value="2" name="chbxTerms" class="custom-control-input">
          <span class="custom-control-label" for="chbxTerms">Custom checkbox</span>
          </label>
          </div>


          working plunker: http://plnkr.co/edit/yy4sshzCnSmuso0XocOX?p=preview






          share|improve this answer



















          • 1





            It worked. Thank you.

            – N'Bayramberdiyev
            Nov 25 '18 at 12:40
















          1














          Wrap the checkbox within a label tag:



          <div class="form-check">
          <label class="form-check-label">
          <input class="form-check-input" type="checkbox" value="1">
          Default checkbox
          </label>
          </div>


          and change your custom checkbox to :



          <div class="form-group">
          <label class="custom-control custom-checkbox">
          <input type="checkbox" value="2" name="chbxTerms" class="custom-control-input">
          <span class="custom-control-label" for="chbxTerms">Custom checkbox</span>
          </label>
          </div>


          working plunker: http://plnkr.co/edit/yy4sshzCnSmuso0XocOX?p=preview






          share|improve this answer



















          • 1





            It worked. Thank you.

            – N'Bayramberdiyev
            Nov 25 '18 at 12:40














          1












          1








          1







          Wrap the checkbox within a label tag:



          <div class="form-check">
          <label class="form-check-label">
          <input class="form-check-input" type="checkbox" value="1">
          Default checkbox
          </label>
          </div>


          and change your custom checkbox to :



          <div class="form-group">
          <label class="custom-control custom-checkbox">
          <input type="checkbox" value="2" name="chbxTerms" class="custom-control-input">
          <span class="custom-control-label" for="chbxTerms">Custom checkbox</span>
          </label>
          </div>


          working plunker: http://plnkr.co/edit/yy4sshzCnSmuso0XocOX?p=preview






          share|improve this answer













          Wrap the checkbox within a label tag:



          <div class="form-check">
          <label class="form-check-label">
          <input class="form-check-input" type="checkbox" value="1">
          Default checkbox
          </label>
          </div>


          and change your custom checkbox to :



          <div class="form-group">
          <label class="custom-control custom-checkbox">
          <input type="checkbox" value="2" name="chbxTerms" class="custom-control-input">
          <span class="custom-control-label" for="chbxTerms">Custom checkbox</span>
          </label>
          </div>


          working plunker: http://plnkr.co/edit/yy4sshzCnSmuso0XocOX?p=preview







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 8:09









          BartoszTermenaBartoszTermena

          7381311




          7381311








          • 1





            It worked. Thank you.

            – N'Bayramberdiyev
            Nov 25 '18 at 12:40














          • 1





            It worked. Thank you.

            – N'Bayramberdiyev
            Nov 25 '18 at 12:40








          1




          1





          It worked. Thank you.

          – N'Bayramberdiyev
          Nov 25 '18 at 12:40





          It worked. Thank you.

          – N'Bayramberdiyev
          Nov 25 '18 at 12:40




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454146%2fbootstrap-4-checkbox-not-working-properly-inside-popover-in-bootstrap-modal%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          Refactoring coordinates for Minecraft Pi buildings written in Python