Hej. Mam problem z dodanie javascript. A dokładnie nie wiem w którym miejscu dodać poniższy javascript tak aby funkcjonował.w moim projekcie ;/
$(document).ready(function() {
$('#example').DataTable( {
initComplete: function () {
this.api().columns().every( function () {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.footer()).empty() )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
} );
}
} );
} );
Poniżej kod z mojego projektu.
@inject('request', 'Illuminate\Http\Request')
@extends('layouts.app')
@section('content')
<h3 class="page-title">@lang('global.assets.title')</h3>
@can('asset_create')
<p>
<a href="{{ route('admin.assets.create') }}" class="btn btn-success">@lang('global.app_add_new')</a>
<a href="#" class="btn btn-warning" style="margin-left:5px;" data-toggle="modal" data-target="#myModal">@lang('global.app_csvImport')</a>
@include('csvImport.modal', ['model' => 'Asset'])
</p>
@endcan
<div class="panel panel-default">
<div class="panel-heading">
@lang('global.app_list')
</div>
<div class="panel-body table-responsive">
<table class="table table-bordered table-striped ajaxTable @can('asset_delete') dt-select @endcan">
<thead>
<tr>
@can('asset_delete')
<th style="text-align:center;"><input type="checkbox" id="select-all" /></th>
@endcan
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th>@lang('xxx')</th>
<th> </th>
</tr>
</thead>
</table>
</div>
</div>
@stop
@section('javascript')
<script>
@can('asset_delete')
window.route_mass_crud_entries_destroy = '{{ route('admin.assets.mass_destroy') }}';
@endcan
$(document).ready(function () {
window.dtDefaultOptions.ajax = '{!! route('admin.assets.index') !!}';
window.dtDefaultOptions.columns = [@can('asset_delete')
{data: 'massDelete', name: 'id', searchable: true, sortable: true},
@endcan{data: 'title', name: 'title'},
{data: 'xxx', name: 'xxx'},
{data: xxx', name: 'xxx'},
{data: 'xxx', name: 'xxx'},
{data: 'xxx', name: 'xxx'},
{data: 'xxx', name: 'xxx'},
{data: 'xxx', name: 'xxx'},
{data: 'xxx', name: 'xxx'},
{data: 'xxx', name: 'xxx},
{data: 'xxx', name: 'xxx'},
{data: 'xxx', name: 'xxx'},
{data: 'xxx', name: 'xxx'},
{data: 'xxx', name: 'xxx'},
{data: 'xxx', name: 'xxx'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
];
processAjaxTables();
});
</script>
@endsection