JavaScript OK and Cancel in a bootstrap modal remove bootstrap modal backdrop,disable bootstrap modal close,disable bootstrap

I would like to implement a classic OK and Cancel concept in a bootstrap modal.

<div class="modal-dialog" role="document">
<div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title" id="myModalLabel">Modal title</h4>
  </div>
  <div class="modal-body">
      user can select an option here from a list
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
    <button type="button" class="btn btn-primary">OK</button>
  </div>
</div>

In the model content, there is a and the user can select one of the options. If OK is clicked, I would like to handle the new option. If not, no action is required. For that I hook on the hide.bs.modal event, but that is called when Cancel is clicked.

How can I differentiate between Cancel and OK buttons?

Answer:1

Well, Bootstrap does not support specific modal events for the modal actions buttons. So, I believe you will have to handle the events yourself like so.

    $("#myModal").on("click","btn-default", function(){
       // code
    });

    $("#myModal").on("click","btn-primary", function(){
       // code
    });
Answer:2

I have a contact form (Drupal Webform) that includes a file upload that creates a form containing this markup (i have stripped the name, size and id attr. in this example): <div class="form-...

I have a contact form (Drupal Webform) that includes a file upload that creates a form containing this markup (i have stripped the name, size and id attr. in this example): <div class="form-...

  1. jquery mousedown not working
  2. jquery mousedown not working chrome
  3. jquery mousedown not working mobile
  4. jquery mousedown doesn't work
  5. jquery mousedown event not working
  6. jquery trigger mousedown not working
  7. jquery mousedown preventdefault not working

I am trying start with promises and angularJS. My backend is returning the correct values, but my html view doesn´t show my table with the data returning from backend. What is wrong here? Here is ...

I am trying start with promises and angularJS. My backend is returning the correct values, but my html view doesn´t show my table with the data returning from backend. What is wrong here? Here is ...

  1. angular updating view
  2. angular view not updating
  3. angular view not updating on model change
  4. angular view not updating until click
  5. angular view not updating after subscribe
  6. angular view not updating on scope change
  7. angular view not updating after model changes
  8. angular 6 view not updating
  9. angular 5 view not updating
  10. angular 4 view not updating
  11. angular array not updating view
  12. angular 7 view not updating
  13. angular observable not updating view
  14. angular setvalue not updating view
  15. angular 8 view not updating
  16. angular model not updating view
  17. angular ngfor not updating view
  18. angular 2 view not updating
  19. angular component view not updating
  20. angular service not updating view

I need to set my xAxis the following values: Values : 63,80,100,125,160,200,250,315,400,500,630,800,1000,1250,1600,2000 The values currently displayed: Values currently: 125,250,375,500,625,750,875,...

I need to set my xAxis the following values: Values : 63,80,100,125,160,200,250,315,400,500,630,800,1000,1250,1600,2000 The values currently displayed: Values currently: 125,250,375,500,625,750,875,...

Suppose we have the following pure function: const HeaderComponent = () => ( <h1> Title <h1> ) export default HeaderComponent Now I need to receive the new title from props, so we ...

Suppose we have the following pure function: const HeaderComponent = () => ( <h1> Title <h1> ) export default HeaderComponent Now I need to receive the new title from props, so we ...