拉拉维尔 4 个不同的页面@section正在破坏脚本
Laravel 4 different pages @section are breaking scripts
我对 laravel 4 很陌生,正在尝试用另一个视图扩展我的布局。
我的layout.blade.php末尾有这个:
{{ HTML::script('js/jquery.nicescroll.min.js') }}
{{ HTML::script('js/jquery.pickmeup.min.js') }}
{{ HTML::script('js/myscript.js') }}
</body>
</html>
然后我有一个文件 page1.blade.php其中我有很多,只显示要点:
@extends('layout/layout')
@section('contents')
<section id="start">
......
</section>
@stop
在这个文件中,myscript.js的所有javascript函数都运行没有任何问题,尽管它们只包含在layout.blade中.php
现在我创建了另一个视图,称为"bookings"及其相应的文件"bookings.blade.php"
这是bookings.blade.php:
@extends('layout/layout')
@section('contents')
<section id="bookingform">
<div id="bookingforma" style="background-color: #00a651; height: 10px; width:100%;">
{{ Form::open(array('url' => 'bookings', 'class' => 'form-inline', 'role' => 'form')) }}
<div class="form-group">
<span><strong>Date available? </strong> </span>
{{ Form::text('from1',Input::get('from'),array('class' => 'form-control', 'id' => 'fromforma')) }}
</div> <span><strong> - </strong></span>
<div class="form-group">
{{ Form::text('to1',Input::get('to'),array('class' => 'form-control', 'id' => 'toforma')) }}
</div> <span><strong> for </strong></span>
<div class="checkbox">
{{ Form::select('persons1', array('1' => '1','2'=>'2','3'=>'3','4'=>'4'),Input::get('persons'),array('class' => 'form-control')) }}
</div>
{{ Form::submit('Request!', array('class' => 'btn btn-success')) }}
{{ Form::close() }}
</div>
</section>
@stop
基本上,我对 @section 和 @stop 和 @extends 所做的与 page1.blade.php 完全相同,但我无法使用任何 javascript 函数。
确切地说,如果我打电话给
var a = document.getElementById('bookingform');
在MyScript.js中,JavaScript也中断了Page1.blade.php的内容。(并且在bookings.blade中不起作用.php)
我的路由.php文件如下:
Route::get('/', function()
{
return View::make('page1');
});
Route::get('index', function() {
return View::make('page1');
});
Route::get('bookings', 'BookingController@getBooking');
Route::post('bookings','BookingController@getBookingDates');
和预订控制器:
class BookingController extends BaseController {
public function getBooking(){
return View::make('bookings');
}
public function getBookingDates()
{
$data = Input::all();
return View::make('bookings');
}
}
关于拉拉维尔,我有什么完全不明白的,还是有人看到了问题?
编辑:
JavaScript:
$(document).ready(function () {
function heightsetter() {
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
y = w.innerHeight || e.clientHeight || g.clientHeight;
return y;
}
var resizeTimeout;
window.onresize = function () {
clearTimeout(resizeTimeout);
var height = document.getElementById('start');
height.style.height = heightsetter() + "px";
var heightz = document.getElementById('hotels');
heightz.style.height = heightsetter() + "px";
var heightd = document.getElementById('training');
heightd.style.height = heightsetter() + "px";
resizeTimeout = setTimeout(function () {
}, 250);
};
var height = document.getElementById('start');
height.style.height = heightsetter() + "px";
var heightz = document.getElementById('hotels');
heightz.style.height = heightsetter() + "px";
var heightd = document.getElementById('training');
heightd.style.height = heightsetter() + "px";
var heightb = document.getElementById('bookingform'); //<<< **this breaks it**
heightb.style.height = heightsetter() + "px";
.....
});
看起来您从未将该 ID 添加到表单本身。您正在尝试访问不存在的内容。
Form::open(array('url' => 'bookings', 'class' => 'form-inline', 'role' => 'form', 'id'=>'bookingForm')
相关文章:
- 当包含另一个asp文件时,是否也包含所有引用的样式和脚本页面
- 借助asp.net验证或java脚本对多个文本进行验证
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- Java脚本时间添加
- 不显示带有本地json文件数据的谷歌地图脚本
- JQuery添加元素需要在我的js之前再次添加JQuery脚本
- 从远程脚本获取用户IP
- 如何根据时间运行不同的脚本
- 如何将字符串值从php页面发送到java脚本页面
- 使用谷歌应用程序脚本将服务器端数据表返回到客户端
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- 当脚本由system.js加载时,如何要求('electron')
- HTML标记在脚本标记中工作
- 是否可以控制获取哪些Google地图脚本(JavaScript API)
- 使用谷歌应用程序脚本从工作表中获取值并将其显示在文本框中
- 显示时间的脚本
- ng应用程序使脚本无限运行
- 如何在运行时在angular 2中加载外部js脚本
- 拉拉维尔 4 个不同的页面@section正在破坏脚本
- @section脚本和ASP.Net WebForm中使用的常用脚本标记之间的区别