Hiding Images on Open

I have a webpage with a menu.  When you select a menu item certain images appear.  This works fine.  The problem that I am having is that when the page opens, all of the images are showing and I need just one menu section to show,  I have attached the files below.  The link to the page is...

http://www.davidschure.com/Template/brushed/index.html
index.html
main.js
main.css
DS928Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom BeckCommented:
This is a long shot but it's easy enough to try. What if you use jQuery to trigger a click of the first item? Something like:
$(window).on('load', function(){
$('#options .option-set a:first').trigger('click');
});

Open in new window

The problem with that is that the filter code has this:
// don't proceed if already selected
if ( $this.hasClass('selected') ) {
	return false;
}

Open in new window

Which means you would need to remove class="selected" from the markup for the first anchor or the filter code will not run. The filter code will re-add the selected class to the first anchor at this line: $this.addClass('selected');
0
DS928Author Commented:
Did not work.  There has to be a way to only show the .music images only.
0
Tom BeckCommented:
Not surprising now that I look at the error console. I saw this code on your page and assumed you had the jQuery library loaded somewhere:
$(document).ready(function(){
    $("#spinner").bind("ajaxSend", function() {
        $(this).show();
    }).bind("ajaxStop", function() {
        $(this).hide();
    }).bind("ajaxError", function() {
        $(this).hide();
    }); 
     });

Open in new window

But now I look at the error console and see this:
No jQuery library.Can you give it a chance to work and include the jQuery library on your page?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

DS928Author Commented:
I have this on the page...
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <!-- jQuery Core>

Open in new window


When I add this..
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

Open in new window


Still the same.  All images showing.

$optionLinks.click(function(){
			var $this = $(this);
			// don't proceed if already selected
			//if ( $this.hasClass('selected') ) {
			  //return false;
			//}

Open in new window

0
Tom BeckCommented:
Yeah, I see it there, way down at the bottom of the page. Which means that any jquery code that you want to run must be below the library in the markup or it will not work. You have errors in the console and not just from the script I suggested. Are you not concerned?
0
DS928Author Commented:
Concerned.  Yes.  But will revisit.  Just need to get this sorted first.

I created a class "no" and put that instead of selected.
$optionLinks.click(function(){
			var $this = $(this);
			// don't proceed if already selected
			if ( $this.hasClass('no') ) {
			return false;
			}

Open in new window


Then on the menu I put this
<li><a href="#filter" data-option-value=".music" class="selected">Music</a></li>
                        <li><a href="#filter" data-option-value=".photo" class="no">Photos</a></li>

Open in new window


And in the CSS this
.item-thumbs .no {
visibility: hidden;
}

Open in new window


Still not working.
0
Tom BeckCommented:
Sorry, you lost me. I did not suggest any changes to main.js or the css classes. I don't know what you are trying to achieve with those changes. I only suggested that you remove class="selected" from the first anchor and trigger a click of the first anchor on page load to filter the thumbnails.

You have errors in the console regarding jQuery scripts failing because the library is being loaded too late on the page. Move the library script block to the head of the page above the first jQuery function call.
0
DS928Author Commented:
I know that it can be confusing.  I simply want only the four album covers to show when the page loads.  Only those in the Music Menu.  Right now both Music and Photos are showing.  After thepage loads the menu and images should function normally. I will move the jQuery call up into the header.
0
Tom BeckCommented:
I am not the least bit confused about the nature of the problem. I have understood from the beginning that you only want the images related to the music to show on initial load. I am trying to help you with that.

Moving the jQuery library to the top has reduced the number of errors and eliminated those referring to the library not being loaded at all.

Now if you could remove class="selected" from the music link we can test my idea.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DS928Author Commented:
Doing now.  So basically on load all of the images show and the list on the left acts as a filter.  I just figured that one out!  LOL!  Trying your idea out now.
0
DS928Author Commented:
Bingo!  It works! Thank you!
0
DS928Author Commented:
Thank you!
0
Tom BeckCommented:
You're welcome.

You still have an error in the console coming from main.js, line 411. All bets are off as long as that error persists. Maybe a new question?

Thanks for the points.
0
DS928Author Commented:
I'm looking now.  Does it say what the error is?  Should I open a new question so that you get more points?  Problem, Sometimes the images load.  Sometimes they don't when I go to the site.  I have to hit the refresh button toe see the images. What can that be?
0
Tom BeckCommented:
I noticed that and like I said, all bets are off until the error on main.js is addressed. I have no idea if it has anything to do with why the images sometimes load, sometimes not, but it would not feel productive to troubleshoot another problem with errors screaming at you especially from main.js.
The remaining console errors."Should I open a new question so that you can get more points?"

Not so I can get more points. I've got plenty. It's time for me to go home anyway. Experts Exchange likes to have just one question per thread so that when someone searches the knowledgebase for solutions, each solution presented is self contained.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.