【发布时间】:2015-10-23 11:07:55
【问题描述】:
为什么我的 js 在 edit.blade.php 视图中不能正常工作。我的观点结构如下:
文件名:profile_main.blade.php
@extends('layouts.main')
@section('head')
@yield('style')
@stop
<!-- Available at the footer of page before body tag closes -->
@section('scripts')
<script src="{{ URL::asset('js/jquery-ui-1.11.4.custom/jquery-ui.js') }}"></script>
<script src="{{ URL::asset('js/search.js') }}"></script>
<script src="{{ URL::asset('js/application.js') }}"></script>
<script type="text/javascript">
$.ajaxSetup({
headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') }
});
</script>
@stop
文件名:training_main.blade.php
@extends('layouts.profile_main')
@section('style')
<link href="{{ URL::asset('css/application/index.css') }}" rel="stylesheet">
@stop
@section('body')
<div id="content-header">
<img alt="user_icon" src="{{ asset('images/general/admission_page_logo.jpg') }}" class="img-responsive"/>
<h1>@yield('page_heading')</h1>
<h3>@yield('page_desc')</h3>
</div>
<hr class="header_underline"/>
@yield('training_body')
@stop
文件名:edit.blade.php
@extends('trainings.training_main')
@section('page_heading')
Edit Training Details
@stop
@section('page_desc')
General
@stop
@section('training_body')
@stop
我在 application.js 中有一些 jquery 函数。我注意到这些函数在 edit.blade.php 中不起作用。例如
文件名:application.js
$("document").ready(function() { alert('Great') });
edit.blade.php 视图加载时不会发出警报。但是当我查看页面源代码时,一切似乎都加载得很好:
<!-- Javascript -->
<script src="http://localhost:8000/js/jquery-1.11.3.js"></script>
<script src="http://localhost:8000/js/bootstrap.min.js"></script>
<script src="http://localhost:8000/js/main.js"></script>
<script src="http://localhost:8000/js/jquery-ui-1.11.4.custom/jquery-ui.js"></script>
<script src="http://localhost:8000/js/search.js"></script>
<script src="http://localhost:8000/js/application.js"></script>
<script type="text/javascript">
$.ajaxSetup({
headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') }
});
</script>
</body>
这可能是什么问题?我缺少什么?
【问题讨论】:
标签: javascript php jquery laravel-5