/* Override the default confirm dialog defined by jQuery UJS */ $.rails.allowAction = function(link){ if (link.data('confirm') == undefined){ return true; } $.rails.showConfirmationDialog(link); return false; } /* Remove the data-confirm from the link so Rails doesn't re-trigger the modal. Then trigger a click of the link. */ $.rails.confirmed = function(link){ link.data('confirm', null); link.trigger('click.rails'); } /* Toggle the Foundation reveal modal when a data-confirm element is clicked. */ $.rails.showConfirmationDialog = function(link){ var el = link.data('confirm'); $('[data-' + el + ']').foundation('open'); } /* General Usage: Link Delete Modal
... OK ...
*/ $(document).on('click', '*[data-reveal-confirm]', function(e){ e.preventDefault(); var el = $(e.currentTarget).data('reveal-confirm'); var link = $('[data-confirm="'+ el + '"]'); var modal = $('[data-' + el + ']'); $(modal).foundation('close'); $.rails.confirmed(link); });