Well, the ideal solution would be if you could find out which button was pressed in any of the callbacks. Unfortunately, I cannot find a way to do this.
onApprove: function () { console.log(this);
So, instead of the above, add event listeners to your buttons. Thus, you know which answer to execute.
<button class="show">Open</button> <div class="ui small modal"> <i class="close icon"></i> <div class="header">Test title</div> <div class="content">Test content</div> <div class="actions"> <div class="ui button approve green" data-value="easy">Easy</div> <div class="ui button approve blue" data-value="normal">Normal</div> <div class="ui button approve red" data-value="hard">Hard</div> </div> </div> <div>Result: <span id="result"></span></div> <script type="text/javascript"> $(document).on("click", ".show", function () { $(".ui.modal").modal("setting", { closable: false, onApprove: function () { return false; } }).modal("show"); }).on("click", ".ui.button", function () { switch ($(this).data("value")) { case 'easy': $("#result").html("easy"); $(".ui.modal").modal("hide"); break; case 'normal': $("#result").html("normal"); $(".ui.modal").modal("hide"); break; case 'hard': $("#result").html("hard"); $(".ui.modal").modal("hide"); break; } }); </script>
Working demo: http://jsfiddle.net/osgg8kzL/1/
source share