I setup bootstrap files in public folder. Routes are as below:
<link rel="stylesheet" href="{{url('assets/css/bootstrap.min.css')}}">
<script type="text/javascript" src="{{url('assets/js/bootstrap.min.js')}}"></script>
<script type="text/javascript" src="{{url('assets/js/jquery.min.js')}}"></script>
<script type="text/javascript" src="{{url('assets/js/tether.min.js')}}"></script>
no problem with this. I can see connection to files when I check the source code. and also bootstrap fonts are active but, when I try to copy some examples from bootstrap website. It doesn't display properly. For example I copied navigation bar to my main.blade But it doesn't show up.
What is causing this? Any idea?
It s big screen but showing responsive hamburger icon?
You should add jquery before bootstrap min js file
<link rel="stylesheet" href="{{url('assets/css/bootstrap.min.css')}}">
<script type="text/javascript" src="{{url('assets/js/jquery.min.js')}}"></script>
<script type="text/javascript" src="{{url('assets/js/tether.min.js')}}"></script>
<script type="text/javascript" src="{{url('assets/js/bootstrap.min.js')}}"></script>
The order in which you add javascript in HTML page is important. In this case since bootstrap.min.js uses jquery.min.js jquery must be added first. So when bootstrap loads and looks for jquery it finds it.
But if one script does not depend on another then you can add them in any order.
So add jquery.min.js first then anything that uses jquery(like bootstrap) after it.
Related
I have been trying to get this tooltip code to initialize on a page and I cannot get the jQuery to connect properly.
We have PHP running on Ubuntu and we are using Silverstripe. I cannot get the following script to work, no matter where or what file I add it to. I have even tried calling it in from a separate file and it also did not initialize.
How would I add this code to a PHP or SS file? (Silverstripe CMS file)
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
<button type=\"button\" class=\"btn btn-default help-tool\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Below you will find state-by-state breakdowns in Federal, State, and where available Local categories.
Explore the data by clicking the map or by clicking the magnifying lens in the table view.\"><i class=\"fa fa-info-circle fa-fw\"></i></button>
This is generally an issue involving the order in which your scripts are called.
As I'm sure you know, you need to call JQuery before Bootstrap, which it seems like you are doing. Your tooltip code, which is in a different file, is most likely being called before your JQuery and Bootstrap have a chance to load. You can test this by copying your JQuery and Bootstrap script calls into your separate file right before the tooltip script call.
If your script calls are at the bottom of your body tag, and part of the page is being dynamically loaded, you can try calling JQuery and Bootstrap in your head tag instead after your CSS:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" src="bootstrap.css" />
<link rel="stylesheet" type="text/css" src="main.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="bootstrap.js"></script>
</head>
<body>
<!--
Your separate file code that
includes tooltip
-->
<!-- Before
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="bootstrap.js"></script>
-->
</body>
</html>
There are two causes that come to mind here. First, it's possible that the $ is getting interpreted by SS's template parser as a variable expression. I would expect you would be getting an error if that is the case. Second, as Sumit Kukreja indicated it's likely that jQuery and Bootstrap are being injected at the bottom of your template and this code is getting executed before those are loaded.
Option 1: To verify if this is happening you could add the following code to Page_Controller::init() or mysite/_config.php:
Requirements::set_write_js_to_body(false);
Which will cause all required javascript to be added in the <head> tag. Not a good idea for production but could help diagnose your problem.
Option 2: You can include that javascript from your controller using Requirements::customScript.
Option 3: Wrap your js snippet in a non-jquery domready listener like so:
document.addEventListener("DOMContentLoaded", function(event) {
$('[data-toggle="tooltip"]').tooltip()
});
I have a laravel project and just wanted to use a simple timer jquery script in it. I created a new folder in views, placed there my code. I also placed there another folder called flip_timer with jquery files.
My problem is that i cannot make the script paths work "not found http exception".
Folder structure looks like this: folder in views > contains file(code below) and folder including all the needed files. Whenever i try to run the link with code the page is empty, and when i click to see the source code and click on the css or js link it shows me the error i mentioned above...
<link rel="stylesheet" type="text/css" href="flip_timer/jquery.flipcountdown.css" />
<script type="text/javascript" src="flip_timer/jquery.min.js"></script>
<script type="text/javascript" src="flip_timer/jquery.flipcountdown.js"></script>
<div id="retroclockbox1">
<script>
jQuery(function($){
$('#retroclockbox1').flipcountdown();
})
</script>
</div>
put your jquery.flipcountdown.css file in inside css folder named: css/flip_timer/jquery.flipcountdown.css
AND
your both js file inside js folder named:js/flip_timer/jquery.min.js and js/flip_timer/jquery.flipcountdown.js and then put below code in your html file.
<link rel="stylesheet" href="{{ URL::asset('css/flip_timer/jquery.flipcountdown.css') }}" />
AND for js file
<script type="text/javascript" src="{{ URL::asset('js/flip_timer/jquery.min.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('js/flip_timer/jquery.flipcountdown.js') }}"></script>
I have big problem here and it seems i dont know that much jQuery so i need help. If someone know this i will be grateful.
I copy everything from their folders and i want to use skin thumbnail 07. Everything was ok when my page stays in ''skin'' folder, but when i take it out, JSSOR showing me just one picture. I cant figure it out where i need to change code...that i dont need to put every single page in ''skin'' folder.
You can check my working code here
And not good one here
Only difference is different place of .php file
Thank you
js file reference path is incorrect.
please replace
<script type="text/javascript" src="../js/jssor.core.js"></script>
<script type="text/javascript" src="../js/jssor.utils.js"></script>
<script type="text/javascript" src="../js/jssor.slider.js"></script>
with
<script type="text/javascript" src="js/jssor.core.js"></script>
<script type="text/javascript" src="js/jssor.utils.js"></script>
<script type="text/javascript" src="js/jssor.slider.js"></script>
I'm trying to use Lightbox with my CodeIgniter application. Lightbox says to put the following in the head tag:
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
I already had a js folder and a css folder, so I put the js and css folders that came with lightbox within my js and css folder. I changed the 3 script tags and link tags to:
<script type="text/javascript" src="js/js/prototype.js"></script>
<script type="text/javascript" src="js/js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/js/lightbox.js"></script>
<link rel="stylesheet" href="css/css/lightbox.css" type="text/css" media="screen" />
(added the /js and /css)
in the view file I have
<img name="<?php echo $row->Thumb;?>" src="http://www.doublediamondllc.com/uploaded/portfolio/thumbs/<?php echo $row->Thumb;?>" alt="">
This displays the thumbnail version, and then when clicked I want it to go to the lightbox, but now it goes to a new tab with the large image.
I've used lightbox before and have always gotten it to work, I'm not really sure what the problem is now, and I tried moving the files all around to different spots but nothing worked.
Thanks in advance!
It seems like the .js isn't getting loaded properly. Try using Firebug, and see if any errors pop up. Alternatively, check the links in the source for the page, and make sure they are pointing to the lightbox js files correctly. If you are using Firefox, view source; the links to the js files should appear as clickable links; click on them and make sure the js file appears, and not a 404 or some other error. Otherwise copy and paste the link attributes to your browser and check the .js paths are correct.
Can anyone please help me how to implement vertical jCarousel by using ajax.
Answer to this question can be easily found on the first pages of jCarousel docs, but okay, I'll copy it here for you ;)
First of all download jCarousel and add all the sources to your <head> tag.
<script type="text/javascript" src="/path/to/jquery-1.2.1.pack.js"></script>
<script type="text/javascript" src="/path/to/lib/jquery.jcarousel.pack.js"></script>
<link rel="stylesheet" type="text/css" href="/path/to/lib/jquery.jcarousel.css" />
<link rel="stylesheet" type="text/css" href="/path/to/skin/skin.css" />
Then in the place where you want your carousel put this code.
<ul id="mycarousel" class="jcarousel-skin-name">
<!-- The content goes in here -->
</ul>
Then add js code to initialize your carousel.
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
// Carousel gonna be vertical
vertical : true,
// AJAX callback
itemLoadCallback: itemLoadCallbackFunction
});
});
</script>
Then you need to create itemLoadCallBackFunction to actually load new items into carousel dynamically. Basicly once you get some item with index i you just insert it to carousel with carousel.add(i, item).
UPD:
Here is an example with PHP script inside, you can get some inspiration from there.