View Full Version : Which event clicking on headers?

11-27-2010, 02:22 PM
1) Script Title: Accordion Content script (v1.9)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ddaccordion.htm

3) Describe problem: I inserted my menus inside a div on which acts a jquery script, but this one gets the click event only when I click on the menu's links, not on menu's headers. How can I manage to get this event in order to make my jquery script react when I click on the headers?

11-27-2010, 05:21 PM
What jQuery script?

Please post a link to a page on your site that contains the problematic code so we can check it out.

11-29-2010, 12:57 AM
You can see the script in action at this page: http://www.sba.unifi.it/CMpro-v-p-120.html.

The jquery script I developed is for fixed positioning of the menus on the right and is:

<script type="text/javascript">

/*** codice per posizionare fissa la colonna dei menu
originale da Fixed Floating Elements: http://jqueryfordesigners.com/fixed-floating-elements/ ***/
// aggiungo classe js a col-right
// racchiudo il contenuto di #col-right dentro div#col-inner
$('#col-right').wrapInner('<div id="col-inner"></div>');
// we capture the initial position of the div
var top = $('#col-inner').offset().top - parseFloat($('#col-inner').css('marginTop').replace(/auto/, 0));

// per pagine con poco contenuto, assegno a #col-moduli una height = altezza #col-inner
var h = $('#col-inner').outerHeight();
if ($('#col-moduli').height() < h) {

$(window).scroll(function(event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// posizione di #col-inner dall'alto
var z = $('#content3').offset().top;

// whether that's below the form
// e se la finestra č pių alta del limite inferiore di #col-inner
if (y>=top) {
// if so, add the fixed class
} else {
// otherwise remove it

$('#col-inner').click(function(event) {
h = $('#col-inner').outerHeight();
var c = $('#col-inner').offset().top;
var f = $('#footer').offset().top;
if (h+c>f) {
$('#col-inner').css({top: f-(h+c) + 'px'});
if (h+c<=f) {
$('#col-inner').css({top: 0 + 'px'});
if ($('#col-moduli').height() < h) {

The script is still in development so sometimes it's not yet doing well its job.
Anyway, the problem I'm referring to is relative to the click(function(event) portion near the end:
- with a screen resolution not greater than 1024x768, if you scroll till the end of the page you can see an overlapping among the menus and the footer,
- now if you click on the header RISORSE twice (firstly it closes, secondly it reopens) the menus don't move so the overlap remains
- differently, if you click on the + and then on the - inside this menu, you can see that the menu move up/down in order to make the overlap disappear (but it's not perfect).
So it seems that clicking on +/- the click event is catched by my script, but not when clicking on the menu's headers.

Following the accordion code of the menus:

headerclass: "menuTitle", //Shared CSS class name of headers group
contentclass: "menuContent", //Shared CSS class name of contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["closedHeader", "openHeader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["suffix", "<img src='images/plus.gif' width='18' height='18'>", "<img src='images/minus.gif' width='18' height='18'>"], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: "normal", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(expandedindices){ //custom code to run when headers have initalized
//do nothing
onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
//do nothing

Thanks a lot.