【发布时间】:2018-01-19 06:30:06
【问题描述】:
我正在尝试laravel
这是我的 welcome.blade.php 文件。
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<style media="screen">
.error{
color: red;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title text-center">
<h1>Laravel</h1>
</div>
<div class="container">
@yield('content')
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
@stack('scripts')
</body>
</html>
现在,这是我的 CountryList.blade.php 我想列出我插入的国家/地区。
@extends('welcome')
@section('content')
<div class="search">
{!! Form::open(['method' => 'GET','route' => ['countries.index'], 'class' => 'form-inline']) !!}
<div class="form-group col-md-6">
{!! Form::text('title', null, ['class'=> 'form-control', 'placholder' => 'Search Name']) !!}
</div>
<div class="form-group col-md-3">
{!! Form::submit('Search', ['class' => 'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
</div>
<div class="country text-center">
<table class="table" id="countriesTable">
<thead>
<tr>
<th>Id</th>
<th>Country</th>
<th>Created Date</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="pages">
</div>
<div class="links">
<a href="{{ route('countries.create') }}">Add A new Country</a>
</div>
</div>
@stop
@push('scripts')
<script>
$(document).ready(function () {
$("#countriesTable").Datatable({
});
});
</script>
@endpush
我遇到了错误:
未捕获的类型错误:$(...).Datatable 不是函数
如果我在处理数据时遇到问题,我可以理解,但无论我按什么顺序保存这个 js,它总是会出现这个错误。
我将.DataTable() 更改为.dataTable() 仍然是一样的。
所有js 都加载到浏览器中。
请帮忙。
【问题讨论】:
-
请尝试 .DataTable() 而不是 Datatable(),在 CamelCase 命名约定中创建函数 谢谢
标签: php jquery laravel datatables