我想在Laravel刀片视图中使用包含文件( properties.blade.php )中的一些javascript函数。
查看( index.blade.php )
@extends('layouts.master')
@section('filters')
@include('partials.filters.properties')
@endsection
@section('content')
<!-- properties start -->
<div class="container">
...
</div>
<!-- properties end -->
@endsection
@section('javascript')
<!-- This is the JS file, I want to include in header as well (functions.js) -->
<script type="text/javascript" src="{{ url('/js/functions.js') }}"></script>
@stop
过滤( properties.blade.php )
<form method="GET" action="{{ route('properties.search') }}">
<div class="row">
<div class="col-lg-9 col-md-9 ui-widget component" id="f_loc">
<div class="form-group">
<input id="input-tags" type="search" name="q" class="form-control input-text input-lg" placeholder="City, Community or Tower">
</div>
</div>
<div class="col-lg-3 col-md-3">
<div class="form-group">
<button class="search-button" onclick="searchSubmit()">Search <i class="fa fa-search"></i></button>
</div>
</div>
</div>
</form>
JS( functions.js )
function searchSubmit() {
localStorage.setItem("search", $('#input-tags').val());
}
答案 0 :(得分:0)
通常,您可以使用刀片的@push
指令来处理JavaScript和CSS,例如,您可以将其添加到@stack('js')
。堆栈将在您关闭的body标签之前。
@section
冒着被替换的风险,如果遇到另一个。
另外作为旁注,您将使用@stop
..