Bootstrap Modal Dialog in Laravel 4 -


i have form in view deleting records , i'd confirm dialog show when delete button clicked. in view 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 sure want delete event?')) }} {{ form::close() }} 

i'd able take data attributes , dynamically populate twitter bootstrap modal dialog using jquery i'm unsure how approach this.

what guys do? basically, when delete button clicked i'd modal window appear title , content data attributes, cancel button , delete button. if user clicks delete button i'd submit form.

it's important note view contains table of records, , each record has delete form/button.

would appreciate 1 folks. cheers.

edit: have now, works doesn't submit 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();     }); }); 

i not using form, link shaped button:

{{ html::link(url::route('event.destroy',$event->id), 'delete', array('class' => 'btn btn-small btn-danger delete-event', 'data-title'=>'delete event', 'data-content' => 'are sure want delete event?', 'onclick'=>'return false;')) }} 

and javascript:

jquery('.delete-event').click(function(evnt) {             var href = jquery(this).attr('href');             var message = jquery(this).attr('data-content');             var title = jquery(this).attr('data-title');              if (!jquery('#dataconfirmmodal').length) {                 jquery('body').append('<div id="dataconfirmmodal" class="modal" role="dialog" aria-labelledby="dataconfirmlabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h3 id="dataconfirmlabel">'+title+'</h3></div><div class="modal-body">'+message+'</div><div class="modal-footer"><button class="btn btn-success" data-dismiss="modal" aria-hidden="true">no</button><a class="btn btn-danger" id="dataconfirmok">yes</a></div></div>');             }               jquery('#dataconfirmmodal').find('.modal-body').text(message);             jquery('#dataconfirmok').attr('href', href);             jquery('#dataconfirmmodal').modal({show:true}); }) 

here's working fiddle: http://jsfiddle.net/antonioribeiro/wybwv/


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -