I have a form in my view for deleting records and I'd like a confirm dialog to show when the delete button is clicked. In my view I have this:
{{ Form::model($event, array('route' => array('events.destroy', $event->id), 'method' => 'Delete')) }} {{ Form::submit('Delete', array('class' => 'btn-small btn-danger delete-event', 'data-toggle' => 'modal', 'data-title' => 'Delete Event', 'data-content' => 'Are you sure you want to delete this event?')) }} {{ Form::close() }} I'd like to be able to take the data attributes and dynamically populate a Twitter Bootstrap modal dialog using jQuery but I'm unsure how to approach this.
What would you guys do? Basically, when the delete button is clicked I'd like a modal window to appear with the title and content from the data attributes, as well as a cancel button and a delete button. If the user clicks the delete button I'd like to submit the form.
It's important to note that this view contains a table of records, and each record has a delete form/button.
Would really appreciate your help with this one folks. Cheers.
EDIT: I have this now, which almost works but it doesn't submit the form?
$('.delete-event').click(function(event) { event.preventDefault(); var title = $(this).attr('data-title'); var content = $(this).attr('data-content'); $('#event-modal').html(title); $('.modal-body p').html(content); $('.modal-footer .delete').html(title); $('#event-delete').modal('show'); $('.delete').click(function(event) { $('#event-delete').modal('toggle'); $('.delete-event').submit(); }); });