admin管理员组文章数量:1336199
I am now trying to use javascripts in my project. I searched all this morning on the Internet, and found nothing really clear about Laravel and Javascript.
Can somebody please explain how exactly (or link me from a known real example), can we make javascripts working on a Laravel project ? Thanks
Here's what i tried :
template_mynet.blade.php
...
{{ HTML::script('assets/js/jquery-2.1.1.js') }}
{{ HTML::script('assets/js/bootstrap.min.js') }}
{{ HTML::script('assets/js/bootstrap.js') }}
{{ HTML::script('assets/js/accueil_hover.js') }}
...
accueil.blade.php
@extends('template_mynet')
@section('content')
<div class="container">
<a id="popoverData" class="btn" href="#" data-content="Popover with data-trigger" rel="popover" data-placement="bottom" data-original-title="Title" data-trigger="hover">Popover with data-trigger</a>
<a id="popoverOption" class="btn" href="#" data-content="Popup with option trigger" rel="popover" data-placement="bottom" data-original-title="Title">Popup with option trigger</a>
</div>
@stop
accueil_hover.js
$('#popoverData').popover();
$('#popoverOption').popover({ trigger: "hover" })
Where are my js files ?
/public/assets/js
What are my files ?
accueil_hover.js
bootstrap.js
bootstrap.min.js
jquery-2-1-1.js
npm.js
Links are here, but the hovering is not working ! This code is from the example linked here : /
I am now trying to use javascripts in my project. I searched all this morning on the Internet, and found nothing really clear about Laravel and Javascript.
Can somebody please explain how exactly (or link me from a known real example), can we make javascripts working on a Laravel project ? Thanks
Here's what i tried :
template_mynet.blade.php
...
{{ HTML::script('assets/js/jquery-2.1.1.js') }}
{{ HTML::script('assets/js/bootstrap.min.js') }}
{{ HTML::script('assets/js/bootstrap.js') }}
{{ HTML::script('assets/js/accueil_hover.js') }}
...
accueil.blade.php
@extends('template_mynet')
@section('content')
<div class="container">
<a id="popoverData" class="btn" href="#" data-content="Popover with data-trigger" rel="popover" data-placement="bottom" data-original-title="Title" data-trigger="hover">Popover with data-trigger</a>
<a id="popoverOption" class="btn" href="#" data-content="Popup with option trigger" rel="popover" data-placement="bottom" data-original-title="Title">Popup with option trigger</a>
</div>
@stop
accueil_hover.js
$('#popoverData').popover();
$('#popoverOption').popover({ trigger: "hover" })
Where are my js files ?
/public/assets/js
What are my files ?
accueil_hover.js
bootstrap.js
bootstrap.min.js
jquery-2-1-1.js
npm.js
Links are here, but the hovering is not working ! This code is from the example linked here : http://jsfiddle/9P64a/
Share asked Nov 7, 2014 at 12:58 Gui OGui O 3834 gold badges10 silver badges22 bronze badges 02 Answers
Reset to default 3You should put your javascript in a document ready function. You javascript code won't work because the document isn't fully loaded yet.
change the javascript code to the following:
$(document).ready(function(){
$('#popoverData').popover();
$('#popoverOption').popover({ trigger: "hover" });
});
If this is still not working, please provide the full html output of your site and any console errors.
I had a weird problem though. The title of the question is the exact same thing but I had document ready function. The culprit was something else and it fixed by menting out
app.js
asset.
本文标签: jqueryLaraveljavascript not working but no errorStack Overflow
版权声明:本文标题:jquery - Laravel - javascript not working but no error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742401372a2467949.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论