button-event.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="../examples/assets/jquery/jquery-1.10.2.min.js"></script>
  5. <link href="../examples/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  6. <script src="../examples/assets/bootstrap/js/bootstrap.min.js"></script>
  7. <link href="../src/css/bootstrap-dialog.css" rel="stylesheet" type="text/css" />
  8. <script src="../src/js/bootstrap-dialog.js"></script>
  9. <title>Button Event</title>
  10. <meta charset="utf-8" />
  11. </head>
  12. <body>
  13. <script type="text/javascript">
  14. $(function() {
  15. var dialog = new BootstrapDialog({
  16. closable: false,
  17. buttons: [{
  18. label: 'Button 1',
  19. action: function(dialog, event) {
  20. // this.data('button') is the original button config
  21. console.log(this.data('button'));
  22. // Stop bubbling. 'event' here is the original event object of 'click'.
  23. event.stopPropagation();
  24. }
  25. }, {
  26. label: 'Button 2',
  27. action: function(dialog) {
  28. // Does nothing
  29. }
  30. }],
  31. onshown: function(dialog) {
  32. var $footer = dialog.getModalFooter();
  33. $footer.on('click', function(event) {
  34. alert('Footer was hit.');
  35. });
  36. }
  37. });
  38. dialog.open();
  39. });
  40. </script>
  41. </body>
  42. </html>