Solved

JavaScript Collapse Box  IMG

Posted on 2010-11-23
4
400 Views
Last Modified: 2012-06-27
I am working in Drupal with a collapseable javascript box.  At the moment, We have Text which you click to open and close the box. What we want to do, and are trying to do, is in place of text, we want an image(Button) to be click-able to open and close the box.

I have tried just inserting an image, but when you click the image button, the box collapses and so does the button, and you are unable to open the box again. If after the button i put a single character in this case "X" i can click the image, to close the box, but only the "X" appears on the closed box.

I have attached a screenshot of the button and X, also the code and file of the collapsible.js.

Could somebody help me with this please.

// Turn the legend into a clickable link and wrap the contents of the fieldset
    // in a div for easier animation
    var text = this.innerHTML;
      $(this).empty().append($('<a href="#">'+ text +'</a>').click(function() {
        var fieldset = $(this).parents('fieldset:first')[0];
        // Don't animate multiple times
        if (!fieldset.animating) {
          fieldset.animating = true;
          Drupal.toggleFieldset(fieldset);
        }
        return false;
      }))
      .after($('<div class="fieldset-wrapper"></div>')
      .append(fieldset.children(':not(legend):not(.action)')))
      .addClass('collapse-processed');

Open in new window


 
 
0
Comment
Question by:jonathan1978
4 Comments
 
LVL 6

Accepted Solution

by:
Codebot earned 500 total points
ID: 34203422
Hi
you can use  div or span  and then call function on onclick event of div.
0
 

Author Comment

by:jonathan1978
ID: 34209766
Sorry to ask, but how would i do that ?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now