I have multiple slideshows but only want one running chosen by id. The rest turned off and hidden.
I have the first one loading onload.
I have a nested for loop running through and turning them on and off.
This is not working consistently.
Some of the code I found on the internet. the outer for loop runs before any id is even chosen.
I don't even know if the active slider is being stopped properly before the new one is activated.
My loops seem to work correctly with just alerts and no code for the slideshow.
Then when I introduce the slideshows it works sometimes but not consistently.
Choosing id 1 or 2 seems to work but sometimes it will not loop through the nested 3 or 4.
Some kind of conflict or is it logic error?
Please help this desperate beginner. I volunteered to do this for our choir
I am sorry that I wasn't able to format the code properly for viewing.
ok, I added jsfiddle
https://jsfiddle.net/5s0q30s8/
with the loops using only alerts.
<button id=1>Group Photos</button>
<button id=2>Miscellaneous</button>
<button id=3>Trips</button>
<button id=4>Old Pictures</button>
<script>
var buttons = document.getElementsByTagName("button");
var buttonsCount = buttons.length;
for (var i=0; i <= buttonsCount; i+=1){
buttons[i].onclick=function(e){
var id= this.id;
alert(id + ' clicked');
for (var i=1; i <= buttonsCount; i+=1){
alert('nested for' + i);
if (i != id) {
var temp = ('.slider-wrapper ' + i)
alert('Not id ' + temp);
$('.slider-wrapper' + i).hide();
/* $('#slider' + i).hide(); */
$('#slider' + i).data('nivoslider').stop();
}
else {
alert('true '+ i);
$('.slider-wrapper' + i).show();
$('#slider' + i).nivoSlider({ effect: 'fade' } );
} //end else
} //end nested for
};
} //end for
</script>
<div class="slider-wrapper1 theme-default">
<div id="slider1" class="nivoSlider">
<img src="images/Choir2014.jpg" alt="" title="2014" />
........More images.
</div>
</div>
<div class="slider-wrapper2 theme-default">
<div id="slider2" class="nivoSlider">
<img src="images/Choir2014.jpg" alt="" title="2014" />
........More images.
</div>
</div>
<div class="slider-wrapper3 theme-default">
<div id="slider3" class="nivoSlider">
<img src="images/Choir2014.jpg" alt="" title="2014" />
........More images.
</div>
</div>
<div class="slider-wrapper4 theme-default">
<div id="slider4" class="nivoSlider">
<img src="images/Choir2014.jpg" alt="" title="2014" />
........More images.
</div>
</div>
<script type="text/javascript">
$(window).load(function() {
$('#slider1').nivoSlider({ effect: 'fade' });
});
</script>
I must say, your code is very messy in my eyes. I do see you made an effort at using jQuery, so I will assume you are able to use that.
Your goal as I understand it:
There are 4 sliders
There are 4 buttons
You click one button, and the respective slideshow shows up.
$('#slideButtons button').click(function(){
var id = $(this).attr("id");
$('#content .slide:visible').hide();
$('#content #c' + id).show();
// Any other logic can be put here, like starting or stopping sliders.
});
/* Show the first slider, and hide everything else by applying display:none to it */
#content div:not(#c1) {
display:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="slideButtons">
<button id="1">1</button>
<button id="2">2</button>
<button id="3">3</button>
<button id="4">4</button>
</div>
<div id="content">
<div class="slide" id="c1">Number 1! Put Slideshow 1 here.</div>
<div class="slide" id="c2">Number 2! Put Slideshow 2 here.</div>
<div class="slide" id="c3">Number 3! Put Slideshow 3 here.</div>
<div class="slide" id="c4">Number 4! Put Slideshow 4 here.</div>
</div>
From here you can build it out. I'm sure it will look a lot cleaner too then. Also, if you are going to debug with that many alerts, try using console.log instead of alert. It's a lot less intrusive and you can simply read through it.
Related
I have numbed a classes on a view drupal 8 row like
<div class="view">
<div class="view-row-1"></div>
<div class="view-row-2"></div>
<div class="view-row-3"></div>
<div class="view-row-4"></div>
</div>
I have added some css for view-row-3 but when i delete contents view-row-2 now total rows count should be changed and now view-row-3 became view-row-2 and view-row-4 became view-row-3 so total css was changed.so i want to re write css
i did the following
select views and
Add Global: View result counter and hide it from display
<div class="views-row-{{ counter }}">
</div>
Now everything is fine.but if delete content is is possible view like
<div class="view">
<div class="view-row-1"></div>
<div class="view-row-3"></div>
<div class="view-row-4"></div>
</div>
or if i add new content then view like
is it possible?please help me
Why don't you just use a css selector like:
div.view div:nth-child(3) {
color:red;
}
I am not an expert in Bootstrap 3. It was my first time to use the widget "datepicker". I have two date pickers that need to be displayed inline to each other. When I try a normal input it works but if it is a date picker it goes a little far at the bottom. I tried the position relative however it did not resolve the issue. See screen shot attached.Date picker goes at the bottom
Hope some one can give me some light. Below is my code.`
<div class="horiz-search-bar-wrapper">
<form class="form-inline">
<div class="form-group">
<label><strong>Search</strong></label>
</div>
<div class="input-daterange">
<div class="form-group rel-position-date">
<label>Check-In:</label>
<div class="input-group input-append date" id="from">
<input type="text" class="form-control">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</div>
<div class="form-group rel-position-date">
<label>Check-Out</label>
<div class="input-group input-append date" id="to">
<input type="text" class="form-control">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group mar-left">
<button type="button" class="btn btn-primary">
Submit
</button>
</div>
</form>
</div>
`
Just an update to this, we were able to fixed the issue by replacing the <label></label> tag to <span></span>. The bootstrap datepicker adds top pixels when it sees more than 1 label.
Hope this could help the others.
I was also seeing issues with the Datepicker appearing too low. Whether the targeted element was toward the top or bottom of the viewport and the Datepicker was respectively orienting itself above or below the element, I was seeing a Datepicker appear "too-low."
Stumbled on to a fix with some JavaScript hackery bound to the DP's "show" event/hook.
Note the use of the native Boostrap CSS utility classes datepicker-orient-top and datepicker-orient-bottom.
$('#DateOfBirthForEditing').datepicker().on("show", function (e) {
var refDatePicker = $('div.datepicker.datepicker-dropdown');
var refDatePickerField = $('#DateOfBirthForEditing');
var fieldPositionTop = refDatePickerField.offset().top;
var dpModalTopOffset = 0;
if (refDatePicker.hasClass('datepicker-orient-top')) {
dpModalTopOffset = fieldPositionTop - 255;
} else if (refDatePicker.hasClass('datepicker-orient-bottom')) {
dpModalTopOffset = fieldPositionTop + 30;
}
refDatePicker.css({ "top": dpModalTopOffset });
});
I want to know how we can make modals which have routes.
In Trello, whenever you click on a card, the route changes from abc.com/b/personal to abc.com/c/some-random-string and the card opens in a modal. Also, when you close the modal, you get redirected to the previous url (abc.com/b/personal).
I want to know how can we achieve this using Emberjs.
Example: https://trello.com/b/ezWgKsol/sales-enterprise-feature-requests-sample
Here is my modal (using foundation) where we delete a record:
<div class="reveal" id="deleteLocationModal" data-reveal>
<div class="row">
<div class="columns">
Are you sure you want to delete this location?
</div>
</div>
<div class="row">
</div>
<div class="row">
<div class="columns">
<button id="cancelButton" class="secondary button" data-close type="button">Cancel</button>
<button id="deleteButton" class="button" {{action "deleteLocation" model}} data-close type="button">Delete</button>
</div>
</div>
</div>
The router has the falling in the actions hash:
actions: {
deleteLocation(model) {
Ember.assert("Params must be provided", model);
model.save().then(( /* response */ ) => {
this.transitionTo('locations'); //locations is my index page.
//flash message to inform the user of success.
});
}, (error) => {
//handle error.
// display flash message
// rollback any dirty attributes
});
}
I hope this helps,
Jeff
I am using Materialize in app ruby on rails and want video stop closing modal Materialize.
Help me please.
<% #chapter.episode.each do |episode| %>
<a class="btn modal-trigger" href="#<%= episode.name %>"><%= episode.name %></a>
<div id="<%= episode.name %>" class="modal">
<i id="close" title="Cerrar" class=" modal-action modal-close waves-green right material-icons">close</i>
<div class="modal-content">
<video id="<%= episode.name %>" width="320" height="240" controls>
<source id="<%= episode.name %>" src="<%= episode.url %>" type="video/mp4; codecs='avc1.42E01E, mp4a.40.2'">
Your browser does not support the video tag.
</video>
</div>
</div>
<% end %>
First of all, you are setting the same id for multiple tags (div, video, source). ID must be unique in entire document.
Considering that you want to stop video when modal close, you can use the callback for complete event (modal close), in your Javascript/jQuery code:
$(document).ready(function(){
var videos = $("video");
$('.modal-trigger').leanModal({
complete: function() {
videos.each(function(){
this.pause();
});
}
});
});
This will pause all videos when modal close.
I know this is an old question, but it came up for me in search. I solved it by adding video into modal when it opens, then removing it when it closes. Here's my work.
$(document).on('click','.video-butt',function(){
$('#video-modal .video-container').html('<iframe id="myIframe" width="300" height="200" src="' + $(this).attr('href') + '?rel=0" allowfullscreen="true" ></iframe>'); // embed video
$('#video-modal').modal('open');
return false;
})
function videoTrash(){ //remove video embed on close
$('#video-modal .video-container').empty();
}
$('#video-modal').modal({onCloseEnd:videoTrash}); // initialize materialize modal
html
<div id="video-modal" class="modal black">
<div class="modal-content white-text">
<div class="video-container"></div>
</div>
</div>
the trigger link
<a class="btn btn-flat video-butt" href="https://www.youtube.com/embed/hO4tW8Py2xc">watch the video</a>
I am encountering an issue with Jquery Mobile :
I want to display a grid of items using three columns. Each new item must be displayed next to the previous one and begin a new line after the third column.
To give you an example, I want something like this : JSFiddle
But my items have to be items from a splitButtonList (an icon with labels on the left and a clickable button on the right) instead of the blocks from the previous example.
The problem is : when I use the kind of code shown below, each new item is display at the bottom of the previous one, like in a list. I cannot manage to display it using my three columns grid pattern JSFiddle.
<body>
<div data-role="page" data-theme="c" id="projets">
<div data-role="header" data-position="fixed" data-theme="f" data-tap-toggle="false" id="banniere">
</div>
<div data-role="content" id="content">
<div class="ui-grid-b">
<ul data-role="listview" data-split-icon="star" data-split-theme="a" class="listview">
<li>
<a href="projects.html">
<img src="img/icon/file.png" />
<h3>A label</h3>
<p>Another one</p>
<p>And finally another one</p>
</a>
Plop
</li>
<li>
<a href="projects.html">
<img src="img/icon/file.png" />
<h3>A label</h3>
<p>Another one</p>
<p>And finally another one</p>
</a>
Plop
</li>
</ul>
</div><!-- /grid-b -->
</div>
<div data-role="footer" data-position="fixed" data-theme="f" data-tap-toggle="false" id="footer">
</div>
</div>
</body>
Do you have any idea of what to do ? Using CSS maybe ? Any clue would be very precious for me. Thank you
How about this? JSFiddle
You were basically missing the 3 child containers of the grid:
<div class="ui-grid-b">
<div class="ui-block-a">Listview 1 goes here...</div>
<div class="ui-block-b">Listview 2 goes here...</div>
<div class="ui-block-c">Listview 3 goes here...</div>
</div><!-- /grid-b -->
So, as you can see you will need three different listview.
Hope this helps!