Dropdown menu popper.js - javascript

I'm trying to make a dropdown menu but I get this error:
"Uncaught Error: Bootstrap dropdown require Popper.js (https://popper.js.org)
at bootstrap.min.js:6
at bootstrap.min.js:6
at bootstrap.min.js:6"
I found some questions about it here but none of them worked for me. How do I import this popper.js?
edit1:
I just found a way to import with script tag...it was all this time in bootstrap documentation. But, there's one more problem: The code is free of erros but my dropdown button isn't working. I tried every single dropdown in bootstrap documentation, I ctrl+c - ctrl-v all of them and none of them are working, I click on the button and nothing happens :(
!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>About us</title>
<link href="bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="Sobre-Nós.css" rel="stylesheet" type="text/css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
</head>

Check this documentation: https://github.com/FezVrasta/popper.js#installation
There are several ways of installing popper.
Good luck!

I solved my problem, it's just:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>

Related

Why dont my cdn file work in the browser?

The HTML code given below does not follow the stylesheet that is provided in the link. I have entered several cdn links but none seem to render to the app.
<!DOCTYPE html>
<html>
<head>
<title>Refugee Stories</title>
<link rel = "stylesheet" href = "index.css">
<meta name = "viewport" content="width = device-width,initial-scale=1.0">
<meta charset="utf-8">
<!-- jQuery Version 1.11.0 -->
<script
src="https://code.jquery.com/jquery-3.5.1.js"
integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
crossorigin="anonymous"></script>
<!-- Bootstrap Core JavaScript -->
<script src="https://raw.githubusercontent.com/IronSummitMedia/startbootstrap/gh-pages/templates/agency/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>
...
</html>
To many jquery and not the right cdn for boostrap...
I have test it... and it seem like your boostrap code is not working... i replace then in my exemple, and make sure that your css file as the right path too :
<!DOCTYPE html>
<html>
<head>
<title>Refugee Stories</title>
<meta name="viewport" content="width = device-width,initial-scale=1.0">
<meta charset="utf-8">
<!-- Style sheet (make sure yout path is valide)-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="index.css">
<!-- Script -->
<!-- JS, Popper.js, and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous">
</script>
</head>
<body>
<!-- Your html -->
</body>
</html>
Hope it can help you continue your project :)

Multiple errors when starting with Bootstrap

I am a beginner with this so it may be basic.
I have included all the files, and try to add a button.
I see the button but when clicked I get this error:
Uncaught ReferenceError: $ is not defined
the code :
<head>
<meta name = "viewport" content="width=device-width, initial-sclase=1">
<title>Create</title>
<link rel="stylesheet" type="text/css" href="Stylesheets/main.css"/>
<link rel="stylesheet" href="Bootstrap/css/bootstrap.min.css"/>
</head>
<body>
<button class="btn btn-success" onclick="$(this).hide();">Clickit</button>
<! --- scripsts
<! --- bootstrap js files
<script src="Bootstrap/js/jquery.min.js"></script>
<script src="Bootstrap/js/bootstrap.min.js"></script>
<! --- my java script file
<script src="javascripts/main.js"></script>
</body>
Assuming this is all my code, I also get some other errors on consule like :
util.js:56 Uncaught TypeError: Cannot read property 'fn' of undefined
at util.js:56
at util.js:10
at bootstrap.min.js:6
at bootstrap.min.js:6
//and this one
Failed to load resource: the server responded with a status of favicon.ico:1
EDIT :
My project has folders structure: Bootstrap->js-> inside jquery.min.js and bootstrap.min.js, all under 1 folder which is my project.
To get bootstrap, go to http://getbootstrap.com/docs/4.1/getting-started/download/. There it tells you what you need to use bootstrap.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
You can also go to http://getbootstrap.com/docs/4.1/getting-started/introduction/ to get the html tags to put in bootstrap.
I think that's probably the problem. Try with those.
Edit:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<button class="btn btn-success" onclick="$(this).hide();">Clickit</button>
</body>
I'm assuming you wanted that?
Well I guess it is too basic so some of you didn't see, my comment was wrong, it should be closed :
<!-- jquery files -->
Now it works.

loading content from another php page into index php page

I have a #container1 div on index.php.
I am trying to load #container1 with the contents of a #container2 div from page1.php.
I cannot figure out why this isn't working.
My file hierarchy is like this:
Project
-Js
--myJs
-index.php
-page1.php
index.php:
<!doctype html>
<html dir="rtl">
<head>
<base href="..\project\">
<title></title>
<link href="https://fonts.googleapis.com/css?family=Amatic+SC|Assistant" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="js/myJs.js"></script>
</head>
<body>
<div id="container">
</div>
</body>
</html>
page1.php
<!doctype html>
<head>
<base href="..\project\">
<title></title>
<link href="https://fonts.googleapis.com/css?family=Amatic+SC|Assistant" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="js/myJs.js"></script>
</head>
<body>
<div id="container2">
<div id="hello" style="height:100px; width:100px; background-color:blue;">
<p>hello<p>
</div>
</div>
</body>
</html>
myJs.js:
$(document).ready(function(){
$("#container").load("../page1.php #container2> *");
});
index otherwise shows up just fine. when I manually put the div #hello into #container1 it displays perfectly.
page1 also shows up well.
debugging didn't tell me much. the code successfully stepped into the function, but the hello is just not showing up.
the console is empty.
You are using jQuery Slim which does not contain any AJAX functionality.
To rectify your problem you need to include the full jQuery library and change the jQuery code slightly.
Replace your jQuery script tag with the following:
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
Then, in myJs.js, change the code to this:
$(document).ready(function(){
$("#container").load("../page1.php #container2");
});
Notice that I have changed the string from ../page1.php #container2> * to what it is above. CSS selectors cannot be used in that way in the load function, instead you can just target one element.
The other thing you might need to do is remove the <base> tag. That's playing havoc with relative URLs.
The console will then tell you the problem Uncaught TypeError: $(...).load is not a function.

Cannot add new elements to slick carousel

I'm using slick to display results returned by ajax.
$('#carousel').slick('slickAdd',html,indexToInsert);
$('#carousel').slick('slickGoTo',indexToInsert);
I have checked the html (if it is correctly rendered) and indexToInsert whose value (with the first query) is zero. However, when I inspect the carousel there is nothing there.
The html is
<table class='table'>
<tr>
<th>Dia</th>
<th>Turno</th>
<th>Função</th>
</tr>
<tr>
<td>2018-07-03</td>
<td>8:00 - 17:00</td>
<td>Folga</td>
</tr>
</table>
I have tested adding static elements at the beginning of the rendering of the page to check if the slick itself was correctly loaded and it was as the elements were correctly displayed.
My includes are as follows:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<link href="../style/datepicker/datepicker.css" rel="stylesheet">
<script src="../style/datepicker/datepicker.js"></script>
<script src="../style/date/date.js"></script>
<script src="../style/carousel/slick.js" ></script>
<link rel="stylesheet" href="../style/carousel/slick-theme.css" />
Can anyone help me?
The behavior was caused by the internal validations of slick when the index==0 and there are no elements in the carousel.

jQuery load method gives error $(...).load is not a function at HTMLDocument.<anonymous>

Im building a page using Bootstrap and still feeling my way around. Im trying to load content to a div once the page has finished loading and Im using jQuery .load method. For some reason it always comes back as : load is not a function, even when Ive copied a working example from w3schools.
My code is as follows:
$(document).ready(function(){
$(".carousel-load").load('HTML/avaleht.html');
})
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-
to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="CSS/bootstrap.min.css" >
<link rel="stylesheet" href="CSS/style.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg" crossorigin="anonymous">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<title>ASMRi</title>
</head>
<div class="carousel-load"></div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
Any sort of help is much appreciated!
You're including jQuery two times in your code, and the latter (slim version) doesn't include load() function in it. Since the latter also overrides the former, you get this error.
You need to remove this line from the code:
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
To see the difference between the two flavors, this post is a good start.

Categories