Uncaught TypeError: $(...).DataTable is not a function
Uncaught TypeError: $(...).DataTable is not a function
YiiDeveloper
Posts: 5Questions: 2Answers: 1
code in my view file is as follow:
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Members';
$this->params['breadcrumbs'][] = $this->title;
<?php
>
?>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js">
</script>
<script src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js">
</script>
<div class="" style="font-size: 1.3em;margin-top: 30px; ">
<table id="example" class="display" >
<thead>
<tr>
<th>Number</th>
<th>Region</th>
<th>District</th>
<th>Name</th>
</tr>
</thead>
</table>
</div>
<script>
$(document).ready(function (){
$('#example').DataTable({
ajax: {
url: 'table',
type: 'POST',
dataSrc: '',
},
columns: [
{ data: 'Number' },
{ data: 'Region' },
{ data: 'District'},
{ data: 'Name' }
],
select: true
});
});
</script>
I have created action controller called actionTable and linked it to the view file. The interesting thing is that the same formula worked for yii1.
This discussion has been closed.
Answers
If you link to the page I'd be happy to take a look. I can't comment on the Yii aspect, but the HTML above looks like it should work.
Allan