3
我使用Bootstrap作爲我的模板,而Laravel作爲我的框架。正如示例中所建議的,您應該在頁面底部加載您的jQuery腳本 - 以加快加載速度。jQuery腳本只在其功能之上工作
在我的申請,我有這個功能,它檢查中存在會話的警報,如果是這樣,表現出來:
:$(document).ready(function() {
toastr.options = {
"closeButton": false
};
toastr. {
{
Session::get('flash_notification.level')
}
}('{{ Session::get('
flash_notification.message ') }}')
});
這上面,我加載jQuery腳本顯示
@if (Session::has('flash_notification.message'))
<script>
The above script is loaded here.
</script>
@endif
@yield('content')
</div>
<!-- Scripts -->
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
爲了得到這個工作,我需要聲明我的jQuery文件模板的頭,但我知道這是不是最好的做法。我最初認爲通過使用$(document).ready()
方法,它可以解決這個問題,但事實並非如此。
任何幫助將不勝感激。