Accordion slider, not displaying content properly - javascript

I have this multi-tiered accordion slider for listing schedules. The problem I am having is once you navigate to the third tier, the entire list disappears and has some weird space at the top. If you follow this link -- Pool League Demo
You can see what I mean once you navigate to the schedules tab. Once there, if you click monday 9 ball > Week 1 , you will see exactly what I mean. Any help is very much appreciated :)
Also, on a side note, I am using scrollIt.js and for some reason am having problems with the active class. When applied, it doesn't do what it is supposed to, and this happens multiple times throughout the page, even in the schedules section which doesn't use scrollit.js. If anyone knows how to get the active class to work, I would really appreciate the help on that as well.
Thanks in advance!!

For your second answer, please try adding the activeClass: 'active' parameter to the $.scrollIt() function call.
e.g. :
$.scrollIt({
activeClass:'active'
});
and make sure the class name you mention has some CSS attached to it.
e.g. :
a.active {
background: #000;
color: fff;
}

Related

Where each variable is equal to spans content add class

The Question and Codes
I am struggling with the below code:
$('.rdsubs-mysubscriptions table tbody tr td a').each(function() {
var subItem = $(this).html();
//console.log(subItem);
var subItemStripped = subItem.substring(12);
console.log(subItemStripped);
$('body').find('span:contains("subItemStripped")').addClass('HELLO');
}); // end of each function
When I check the console for subItemStripped then it shows this:
Framework
Content
Slideshow
Which means (in my head at least ;-)) that for each span that is inside the body it should find one of these subItemStripped and where it finds a match it should add the class hello but this is not happening.
Actually, nothing is happening.
When I change this line:
$('body').find('span:contains("subItemStripped")').addClass('HELLO');
to
$('body').find('span:contains("Framework")').addClass('HELLO');
It works nicely. So am I putting the variable subItemStripped wrongly in there or has it something to do with the .each() function.
I tried the below things to make it work
With the above code I tried a couple of variations before I came here:
$('body').find('span:contains(subItemStripped)').addClass('HELLO');
$('body').find("span:contains('subItemStripped')").addClass('HELLO');
I also tried it with completely different sets of code I gathered from other SO posts but none of those worked. Why I don't know.
$("span").filter(function() {
return $(this).text() === subItemStripped;
}).addClass("hello");
$("span").filter(function() {
return $(this).text() === subItemStripped;
}).css("font-size", "6px");
Why do I need this
I know I don't have to explain why I need this but it could be useful in coming up with other great ideas if the above is not feasible.
I have a webpage and on that page is a menu filled with products that a user can download if he/she has access.
Each menu item has a span with the title in it. Those titles are built up like: Framework Content Slideshow
On this same page is also a component that shows all the users subscriptions.
With the above code, I look to all the subscriptions of the user. Which returns
CompanyName Framework CompanyName Content CompanyName Slideshow
Then I Strip .substring(12) all the parts that I know are not present inside the menu. Which leaves me with Framework Content Slideshow
At this point, I know that some menu titles and the stripped item are the same and for every match, I want to add a class upon which I can then add some CSS or whatnot.
Hopefully, the question is clear and thanks to everyone in advance for helping me out.
#gaetanoM You are completely right. Right after I posted the question I came on this site:
jQuery contains() with a variable syntax
And found the answer which is the same as you are saying!
$('body').find("span:contains('" + subItemStripped + "')").addClass('HELLO');
Thanks so much!
#gaetanoM Can you make your comment in an answer? Then I can select it as the accepted answer. I am answering this question now just to make sure it has an answer. As people get punished for asking questions that don't get answers.

Show/Hide Div, of divers DIV's

I'm new to this site.
Javascript is not much, but I found a code to show and hide divs.
This is what I have for now, when clicking on Details1 also shown Details2
jsfiddle.net/qU3TG/3/
How I can do to make the effect only to the current item?
example:
If I have the options Details 1 Details 2, 3 ..... Details DetailsN, clicking on Details # shows only the div that belongs.
The effect Show / Hide, applies to everyone, not just one. I would like to help me with this code or wish I could recommend another code
I have almost one day trying to fix this problem but I couldn't fix it.
Based on your jsFiddle, I've renamed the links inside hidden blocks:
hide
then updated the jQuery code:
jsFiddle
Use this as in your jQuery part:
$('.slidingDiv .hide').click(function(){
$(this).parent().slideToggle();
});
This will cause the parent div which contains the hide anchor to toggle. I hope this is what you needed

jQuery Accordion/Toggle Panel - Only close/open specific classes

Community!
I really need your help now. I wanted to make an accordion in which I can open all Tabs. By searching the Web I found a good solution:
http://jsbin.com/eqape/968/edit
The first Div-Container of each Section is the one who closes/opens up. I want to define 3 div-Containers. One at the top (always displayed), one in the center (with the toggle-functionality) and one on the bottom (always displayed). Is this possible ? And how can I do this ? I'm new to jQuery so this drives me crazy.
Thank you, guys!
I think you're trying too hard. If I understand correctly, you simply want any .top to toggle the adjacent .content. Since I'm more familiar working in JSFiddle, I've set the code up there:
http://jsfiddle.net/SuyS2/1/
$('.top').click(function () {
$(this).next('.content').slideToggle();
});
Let me know if I'm missing something.
UPDATE:
If you had wanted the sections and the inner content to toggle, you could do this:
http://jsfiddle.net/SuyS2/5/
$('.section-heading').click(function () {
$(this).next('.section-wrapper').slideToggle();
});
$('.top').click(function () {
$(this).next('.content').slideToggle();
});

setting a class to a menu depending of the url link

Here is my scenario, my sub pages are not recognizing the parent, probably cause I set the structure bad, however going to back to fix that is not an option for now, problem the menu parent is getting the parent class in the wrong places....
So what I need to achieve...
if I have this url structure: domain.com/products/.... assign "current" class to menu X...
If I have this other: domain.com/sales/..... assign "current" class to Y....
I know I can do it via javascript, however I lack of knowledge of it, I'm just looking for a solid starting point.
I would appreciate any help.
Thanks in advanced.
You can check the url and do your class assignment like this:
if(document.location.href.indexOf('products') > 0){
$("#somediv").addClass("current");
}
Without providing some sample of you're structure I can't really put together a more meaningful sample but you can see maybe how this would work out.

jCarouselLite not working with <3 list items

EDIT: This is not a problem with the jQuery creating the appropriate markup from SharePoint Announcement List to use jCarouselLite. It seems to be a problem within jCarouselLite. I have done another jsfiddle with just the appropriate markup, not the jQuery/javascript conversion code, and the problem still occurs.
You can see the problem at http://jsfiddle.net/ayatollah/6RKNx/
Again it is only a problem with 1 or 2 list items. 3+ works fine. Should I be changing the markup, our jCarouselLite calling code to fix this?
Bounty will be offered as soon as it's available!
ORIGINAL===============================================================================
I have an Announcement List in a Sharepoint site that I want to convert to a jCarousel. The Announcement List is rendered as a table so I have put together some jQuery code to convert it to the required ul structure.
The jQuery seems to be doing its job but the jCarousel gives some weird behaviour. The first announcement displays as it should, then the second announcement scrolls in as it should. However, for each scroll after this it flashes up the first announcement, then scrolls in the second. When it should just scroll in the first again.
I had it working correctly but it was displaying blank announcements, so I introduced some code to filter out the blank announcements. Here is a jsfiddle to show you the problem.
http://jsfiddle.net/RzeEX/2/
The only change I made from the previous code was to add the extra boolean value:
&& $(listitem).text() != "\xa0"
Seen at: http://jsfiddle.net/RzeEX/3/
However, in the above fiddle the code works exactly as the previous one, but on my server it displays an extra blank announcement. Don't know why I can't replicate it here.
Anyway, anyone have any ideas?
EDIT: Actually just testing it with more than 2 announcements and it seems to work. See http://jsfiddle.net/RzeEX/4/
It is now working as expected, but have 2 announcements and it is still broke, have 1 announcement and nothing shows! It must be something to do with the jQuery as I would believe the jCarouselLite plugin to work.
See http://jsfiddle.net/RzeEX/5/ for the single announcement.
Since it is my understanding that you might have a dynamic list of elements, you can do something like this:
$('.viewport').jCarouselLite({
auto:1000,
speed:1000,
visible: $('#announcementList li').length
});
That way it won't matter if you have 1, 2 or 100 elements. It will always work as it should.
Here's the jsfiddle: http://jsfiddle.net/XS87c/
I think by setting visible:2 may give the desire result.
$('.viewport').jCarouselLite({
auto:5000,
speed:1000,
visible:2
});
let me know if it does not work.
how many do you want to be visible? what behaviour do you want if there is < # visible. I ran into this exact problem, and solved it by not applying the carosel if there was < # visible in the list.
something like this should do the trick:
if ((document.getElementById('viewport') != null) && $('#announcementList').find('li').length >= 3 ) {
$('.viewport').jCarouselLite({
auto: 5000,
speed: 1000
});
}
Complementing the solution of Irfan, you can do:
if(document.getElementById('viewport') != null) {
var options = {auto:5000,speed:1000};
//Here we count the number of items and set it for a better display for 2 and 1 item
if($('#viewport a').length <= 2) {
options.visible = $('#viewport a').length;
}
$('.viewport').jCarouselLite(options);
}
So if you have on or two elements you will see just one or two. But if you have more than two elements you will see just three elements.

Categories