Open MichaelEugeneYuen opened 6 years ago
I am trying to create a custom toastrPrompt() function and get the return value(s)
<button type="button" class="btn btn-danger btn-delete">Delete</button>
$('.btn-delete').click( function(){ var result = toastrPrompt(); console.log(result); }) function toastrPrompt() { toastr.options = { progressBar: true, showMethod: 'slideDown', timeOut: 0, tapToDismiss: false, extendedTimeOut: 0, }; toastr.success('<br><br><button type="button" id="delete" class="btn btn-danger">Yes</button> <button type="button" id="close" class="btn btn-default">Cancel</button>', 'delete item?', { closeButton: false, allowHtml: true, onShown: function () { $("#delete").click(function(){ $(this).closest('.toast').fadeOut(); return 'true'; }); $("#close").click(function(){ $(this).closest('.toast').fadeOut(); return 'false'; }); } }); }
jsfiddle
This doesn't seem like a Toastr issue really, more of a general javascript issue. Perhaps it's best to post this question on StackOverflow..
I am trying to create a custom toastrPrompt() function and get the return value(s)
<button type="button" class="btn btn-danger btn-delete">Delete</button>
jsfiddle