php - jQueryUI on Laravel Blade -
i implementing jqueryui laravel app, want have delete confirmation, i'm failing implement one. here code:
@foreach(array_chunk($items->all(), 3) $row) <div class="row" style="margin-bottom:40px;"> @foreach ($row $item) <div class="col-md-4"> <img src="{{$item->img_loc}}"> <div> <strong>breed: </strong>{{ $item->bname}}<br/> <strong>gamefarm: </strong>{{ $item->g_origin}}<br/> <strong>leg band: </strong>{{ $item->lband}} <h3><a href="{{ action('gamefarmscontroller@edit', $item->id) }}" >edit</a>|<a id="thelink" href="#">delete</a></h3> </div> </div> @endforeach
and here jquery:
<script> $(function() { $( "#dialog-confirm" ).dialog( { autoopen: false, resizable: false, height:140, modal: true, buttons: { "delete": function() { $( ).dialog( "close" ); }, cancel: function() { $( ).dialog( "close" ); } } }); }); </script>
i want make program redirected controller code, carries $items->id looped on @ top code edit.
{{ action('gamefarmscontroller@delete', $item->id) }}
i tried experimenting on code, nothing happens.
edit: here remaining script:
<script type="text/javascript"> $(document).ready(function(){ $('#thelink').click(function(){ $('#dialog-confirm').dialog('open'); }); }); </script>
add href
deleting links below
<a class="confirmlink" href="{{ action('gamefarmscontroller@delete', $item->id) }}">delete</a>
then in js
<script type="text/javascript"> $(document).ready(function() { $("#dialog-confirm").dialog({ autoopen: false, modal: true }); }); $(".confirmlink").click(function(e) { e.preventdefault(); var targeturl = $(this).attr("href"); // url of // href="{{ action('gamefarmscontroller@delete', $item->id) }}" $("#dialog-confirm").html("confirm dialog box"); $("#dialog-confirm").dialog({ title: "confirmation", buttons: { "delete": function () { $(this).dialog('close'); window.location.href = targeturl; // change browser path url in delete link }, "cancel": function () { $(this).dialog('close'); callback(false); } } }); $("#dialog-confirm").dialog("open"); }); </script>
Comments
Post a Comment