button-event.html 2.0 KB

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