I'm using bootstrap jumbotron, and I want insert a google map inside, but I'm having a problem. I'm able to insert the map, but in this jumbtron I have also an alert that isn't shown anymore after I put the map.
<div class="jumbotron" id="jumbotron">
<div class="container theme-showcase" role="main">
<div class="alert alert-warning" role="alert">
<strong>Warning!</strong> Best check yo self, you're not looking too good.
</div>
</div>
</div>
<script>
function initMap() {
var mapDiv = document.getElementById('jumbotron');
var map = new google.maps.Map(mapDiv, {
center: {lat: 44.540, lng: -78.546},
zoom: 8
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?callback=initMap"
async defer></script>
Alert that should be shown:
How it is shown after map is inserted:
EDIT:
The alert div is shown below the map, despite the fact the absolute position of the same alert
New code:
<div class="jumbotron">
<div class="container theme-showcase" role="main">
<div class="alert alert-warning" role="alert">
<strong>Warning!</strong> Best check yo self, you're not looking too good.
</div>
</div>
<div id="map"></div>
</div>
Related
I try to use Swiper js in my wordpress website with my custom theme.
https://swiperjs.com/demos/270-mousewheel-control/core.html
I always have a js error in my console : 'Swiper' is not defined
My code :
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
<div class="swiper-slide">Slide 6</div>
<div class="swiper-slide">Slide 7</div>
<div class="swiper-slide">Slide 8</div>
<div class="swiper-slide">Slide 9</div>
</div>
<div class="swiper-pagination"></div>
</div>
In my custom JS file, i add :
var swiper = new Swiper(".swiper-container", {
direction: "vertical",
slidesPerView: 1,
spaceBetween: 30,
mousewheel: true,
pagination: {
el: ".swiper-pagination",
clickable: true,
},
});
I was going crazy trying to resolve the same issue.
Example Swiper script:
https://codepen.io/simranthapa/pen/eYmjYYw
In my case the issue was:
When using code from codepen.io, you have to click on 'settings' to check if any external css/js are required to make the script work. Don't just rely on the content it shows you in the 3 boxes, as that is not always the full code.
Add the JS files from the CDN to your header.php file. There should be one for the full swiper code and one for jquery in general, eg:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js></script>
and:
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.1/js/swiper.min.js"></script>
Add the page jquery in the wordpress page you want the swiper to appear, but wrap it in this:
jQuery(document).ready(function() {
//your code here
});
All 3 issues needed addressing before the slider/swiper finally worked!
Hope this helps somebody.
Might not be the most optimised approach, but it proves that it CAN work and that you are still sane.
I'm learning to use Swiper Sldier in a website using wordpress and Divi theme. I also try to follow a previous thread as a guide.
After following the instruction, the slider does not work, the imgage stuck at the left screen and it does not move as I drag them.
Here is the code on functions.php
/** Function SSwiper **/
function swiper_magic() {
wp_enqueue_script('swiper','https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js', array ('jquery'));
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
add_action( 'wp_enqueue_scripts', 'swiper_magic' );
On my header:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js"></script>
<script>
$(document).ready(function(){
var mySwiper = new Swiper('.swiper-container',{
pagination: '.pagination',
loop:true,
grabCursor: true,
paginationClickable: true
})
jQuery('.arrow-left').on('click', function(e){
e.preventDefault()
mySwiper.swipePrev()
})
jQuery('.arrow-right').on('click', function(e){
e.preventDefault()
mySwiper.swipeNext()
})
})
</script>
And this is my HTML
<div class="device">
<a class="arrow-left" href="#"></a>
<a class="arrow-right" href="#"></a>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide"> <img src="/images/slider1-1.png"> </div>
<div class="swiper-slide"> <img src="/images/slider1-2.png"> </div>
<div class="swiper-slide">
<div class="content-slide">
<p class="title">Slide with HTML</p>
<p>You can put any HTML inside of slide with any layout, not only images, even another Swiper!</p>
</div>
</div>
</div>
</div>
<div class="pagination"></div>
</div>
I don't know why it did not work.
Any help or general suggestions would be greatly appreciated...
Base on swiper demos, I suggest to put your script at the bottom. To work with swiper arrow button the easiest way are:
var swiper = new Swiper('.swiper-container', {
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
pagination: {
el: '.swiper-pagination',
},
});
And your html would be:
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
</div>
<!-- Add Arrows -->
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
<!-- Add Pagination -->
<div class="swiper-pagination"></div>
</div>
Then, if you want to run the callback. Simply use:
swiper.on('slideChange', function () {
console.log('slide changed');
});
slideChange are the event depend how do you want to run the callback. See full swiper event and method
Use this for your php function
function swiper_magic() {
wp_enqueue_script('swiper','https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js', array ('jquery'), true); // true to load at the bottom after jquery
}
add_action( 'wp_enqueue_scripts', 'swiper_magic' );
Hope this help! ;)
I have abround 6000 documents in my mongo collection, which I need to load up into meteor client upon app startup.
In my routes (located under app/client), I have this:
Router.map(function() {
this.route('home', {
path: '/',
template: 'dashboardWrapper',
waitOn: function() {
return Meteor.subscribe('nasdaq');
},
cache: true
});
});
My dashboardWrapper template looks like this:
<template name="dashboardWrapper">
{{#if Template.subscriptionsReady}}
{{> dashboard}}
{{/if}}
</template>
My dashboard template looks like this:
<template name="dashboard">
<div class="container">
<h2>Priority - 1 Incidents Over Time</h2>
<div class="row">
<div id="yearly-bubble-chart" class="dc-chart">
<strong>Yearly Performance</strong> (radius: fluctuation/index ratio, color: gain/loss)
</div>
</div>
<div class="row">
<div id="gain-loss-chart">
<strong>Days by Gain/Loss</strong>
<a class="reset" href="javascript:gainOrLossChart.filterAll();dc.redrawAll();" style="display: none;">reset</a>
<div class="clearfix"></div>
</div>
<div id="quarter-chart">
<strong>Quarters</strong>
<a class="reset" href="javascript:quarterChart.filterAll();dc.redrawAll();" style="display: none;">reset</a>
<div class="clearfix"></div>
</div>
<div id="day-of-week-chart">
<strong>Day of Week</strong>
<a class="reset" href="javascript:dayOfWeekChart.filterAll();dc.redrawAll();" style="display: none;">reset</a>
<div class="clearfix"></div>
</div>
<div id="fluctuation-chart">
<strong>Days by Fluctuation(%)</strong>
<span class="reset" style="display: none;">range: <span class="filter"></span></span>
<a class="reset" href="javascript:fluctuationChart.filterAll();dc.redrawAll();" style="display: none;">reset</a>
<div class="clearfix"></div>
</div>
</div>
<div class="row">
<div id="monthly-move-chart">
<strong>Monthly Index Abs Move & Volume/500,000 Chart</strong>
<span class="reset" style="display: none;">range: <span class="filter"></span></span>
<a class="reset" href="javascript:moveChart.filterAll();volumeChart.filterAll();dc.redrawAll();"
style="display: none;">reset</a>
<div class="clearfix"></div>
</div>
</div>
<div class="row">
<div id="monthly-volume-chart">
</div>
<p class="muted pull-right" style="margin-right: 15px;">select a time range to zoom in</p>
</div>
<div class="row">
<div>
<div class="dc-data-count">
<span class="filter-count"></span> selected out of <span class="total-count"></span> records | Reset All
</div>
</div>
<table class="table table-hover dc-data-table">
</table>
</div>
<div class="clearfix"></div>
</div>
</template>
The relevant part of Meteor.client looks like this:
if (Meteor.isClient) {
var ndx,data;
Template.dashboardWrapper.onCreated( function() {
var template = this;
template.subscribe("nasdaq");
});
Template.dashboard.onCreated( function() {
data = Nasdaq.find().fetch();
ndx = crossfilter(data);
});
Template.dashboard.onRendered(function(){
var self = this;
self.subscribe("nasdaq", function() {
self.autorun(function() {
data = Nasdaq.find().fetch();
});
});
What I expect from this, is for the dashboard template to wait until all the data from the Nasdaq collection loads up.
What happens is absolutely nothing - no data and no errors.
If I remove ironRounter all together, and refresh, I can get a couple of dozen records (out of 6000 total).
Is there a way reliably force the app to wait until every single document loads up?
Try subscribe right before load the current template, may be it will work.
Router.route('/dashboardWrapper/:_id', {
name: 'dashboardWrapper',
waitOn: function () {
return [
Meteor.subscribe('nasdaq')
];
},
data: function () {
return Nasdaq.findOne(this.params._id);
}
});
I have created a simple Bootstrap3 layout and want to use blaze templates in meteor but the content from my template is always rendered after my HTML structure.
Here is the code:
<head>
<title>demo app</title>
</head>
<body>
{{#Layout template="mainLayout"}}
{{#contentFor region="main-content"}}
This is the main content area
{{/contentFor}}
{{/Layout}}
</body>
<template name="home">
{{welcomeText}}
</template>
<template name="mainLayout">
<div class="container">
<div class="row">
<div class="col-sm-6">LOGO</div>
<div class="col-sm-6">LOGIN BUTTONS</div>
</div><!-- /header row -->
<div class="row">
<div class="col-sm-12">
<!-- navigation -->
</div>
</div><!-- /nav row -->
<div class="row">
<div class="col-sm-12">
{{> yield region="main-content"}}
</div>
</div><!-- /content row -->
</div><!-- /container -->
</template>
The JavaScript:
if (Meteor.isClient) {
Template.home.welcomeText = function () {
return "Welcome to my site.";
};
}
When I run this, the Bootstrap3 structure works fine but welcomeText is rendered underneath the container.
It seems that I overlooked to pass layoutTemplate option to my iron router route - now it works.
I'm currently building a website but I noticed the slider doesn't work in IE8. When I click on the compatibility mode button it does work.
It shows some strangely misplaced divs when I viewed in IE8. I recently built in Pie for the rounded corners to work in IE8; maybe that's the problem with the slider?
Is there anyone that can help me?
Here's the code :)
<div class="slider-container">
<div id="slideshow">
<div>
<div class="caption rc">
<div class="caption-text">
<?php perch_content('tekst slide 1'); ?>
</div>
</div>
<img src="img/slider.jpg" alt="Slide">
</div>
<div>
<div class="caption rc">
<div class="caption-text">
<?php perch_content('tekst slide 2'); ?>
</div>
</div>
<img src="img/slider-2.jpg" alt="Slide">
</div>
<div>
<div class="caption rc">
<div class="caption-text">
<?php perch_content('tekst slide 3'); ?>
</div>
</div>
<img src="img/slider-3.jpg" alt="Slide">
</div>
<div>
<div class="caption rc">
<div class="caption-text">
<?php perch_content('tekst slide 4'); ?>
</div>
</div>
<img src="img/slider-4.jpg" alt="Slide">
</div>
</div>
</div>
And here:
$(function() {
$("#slideshow > div:gt(0)").hide();
setInterval(function() {
$('#slideshow > div:first')
.fadeOut(1000)
.next()
.fadeIn(1000)
.end()
.appendTo('#slideshow');
}, 6000);
});
The strange thing is that it will work in compatibility mode, but not in normal mode, in IE8 and in Firefox, Chrome, and Safari it's working fine.
You are using a cdn, sometimes there is trouble loading cdn files...
Try adding a fallback script to load jquery from your local server.
Add this after your jquery script from google cdn in the header and modify your path.
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='path to jquery libary' type='text/javascript'%3E%3C/script%3E"));
}
</script>
Hope this helps
regards