0

Hi! I am looking to make an adjustment to this script. I'm trying to find a way to do it as neatly as possible, and without breaking any pre-existing functionality.

The code is here, with its corresponding tutorial:

http://tympanus.net/codrops/2011/03/28/moving-boxes-content/

What I'm trying to do is have the first section open by default. What makes this a challenge for me is that the boxes that assemble to create the content wrapper are drawn on page initialization.

Any suggestions would be greatly appreciated, and I'll do my best to pay it forward.

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Airshow
1

ari$av3s,

I think it's easy (but I have said that before).

(untested) In the demo script, try adding right at the bottom of the $(function() {...}); a line, which stimulates a click on the first menu item:

/*
	call the init method of Menu
*/
	Menu.init();
	$("#mb_menu a").eq(0).click();//this is the added line
});

Airshow

Votes + Comments
Elegant solution!
0

An elegant and simple solution. Thank you! I am guessing that same line be modified [with appropriate div] to simulate a first click in any similar setup?

0

An elegant and simple solution. Thank you! I am guessing that same line be modified [with appropriate div] to simulate a first click in any similar setup?

Yes, exactly so.

If you can identify the required element with a jquery selector (and/or selection methods), and it's clickable, then .click() simulates the user interaction left-single-click (though not in every respect - for example, the "clicked" element does not take focus).

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.