Auto close expand collapse

Permalink
Is there a way to configure the expand collapse to auto close when clicking outside the div ?
Thank you

View Replies: View Best Answer
citytech2 replied on at Permalink Best Answer Reply
citytech2
Yes its possible. You just need to write little bit Jquery to accomplish this. The process is pretty same as lightbox effect.
You should define a empty div before ending the body tag. e.g.
<div id="layer"></div>

And then a small piece of Jquery code.
$('#layer').click(function{
    $('#your-expand-collapse-div-id').collapse();
});

But you need to put some css to accomplish this. Hope it will help.

Citytech
ptityop replied on at Permalink Reply
thank you
Atreu replied on at Permalink Reply
Hello. I have the same question and I have done what you listed but am still having issues. I put the JS snippet in as well as added the Div. However, I would like to make sure that I am putting them in the right spots. Would you mind clarifying where exactly? Thank you so much!
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
You need to add the div just before ending the body tag. like:
<div id="layer"></div>
</body>
</html>


And put the javascript in your header.php file, if still it will not work, then send me the page url where you did the trick. I'll look into it.

Rony
ptityop replied on at Permalink Reply
Hi ! Thanks for the reply .... might sound like a stupid question, but where is this header.php file ??
Many thanks
Atreu replied on at Permalink Reply
Usually within the Elements folder of your theme.
ptityop replied on at Permalink Reply
Are you saying I should creat a header.php file ? In my themes/elements folder I only have a misc.html file and a javascript and css folder ....
Atreu replied on at Permalink Reply
It can depend on the theme. Are you using a custom one or one from the marketplace? If so, which one? I will look for you.
ptityop replied on at Permalink Reply
I'm using my own theme.