我有一个带方法的控制器返回
之后的数据表return Datatables::of($menu)
-> edit_column('name', '<a href="{{{ URL::to(\'admin/project/\' . $id ) }}}" >{{$name}}</a>')
-> add_column('actions', '<a href="{{{ URL::to(\'admin/photo/\' . $id . \'/edit\' ) }}}" class="btn btn-success btn-sm iframe" ><span class="glyphicon glyphicon-pencil"></span> {{ Lang::get("admin/modal.edit") }}</a>')
-> make();
用于检索数据的ajax脚本
<script type="text/javascript">
var oTable;
$(document).ready(function () {
oTable = $('#table').dataTable({
"sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
"sPaginationType": "bootstrap",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "{{ URL::to('admin/menu/data/'.((isset($album))?$album->id:0)) }}",
"fnDrawCallback": function (oSettings) {
$(".iframe").colorbox({
iframe: true,
width: "80%",
height: "80%",
onClosed: function () {
window.location.reload();
}
});
}
});
var startPosition;
var endPosition;
$("#table tbody").sortable({
cursor: "move",
start: function (event, ui) {
startPosition = ui.item.prevAll().length + 1;
},
update: function (event, ui) {
endPosition = ui.item.prevAll().length + 1;
var navigationList = "";
$('#table #row').each(function (i) {
navigationList = navigationList + ',' + $(this).val();
});
$.getJSON("{{ URL::to('admin/menu/reorder') }}", {
list: navigationList
}, function (data) {
});
}
});
});
</script>
答案 0 :(得分:1)
->addColumn('actions', function ($menu) {
$test = '<a href="{{{ URL::to(\'admin/photo/\' . $id . \'/edit\' ) }}}" class="btn btn-success btn-sm iframe" ><span class="glyphicon glyphicon-pencil"></span> {{ Lang::get("admin/modal.edit") }}</a>';
return $test;
})->make();