tags:

views:

39

answers:

2

Hello,

i am running into the same problem again,

i have some display:none elements on my site and i cant´t apply jquery plugins on them. i am using the jScrollPane Plugin for example. http://www.kelvinluck.com/assets/jquery/jScrollPane/jScrollPane.html

with:

$(function()
{
    $('.scroll-pane').jScrollPane();
});

you can activate it, but only on visible block elements. what i am doing now is aplying it right after the display:none element has been clicked to display:block

$(".hidden").click(
{
    $('.hidden').show().jScrollPane();
});

is there a trick to make those work right away, meaning making them not ignore display:none elements? thx

+1  A: 

Instead of using display: none, You can set them to visibility: hidden and height: 0 instead and these plugins should work.

.element {
  visibility: hidden;
  height: 0;
}

Otherwise, you have to set display: inline|block|whatever before the plugin command is called.

Shawn Steward
yes but then i have to change height after the click too and i dont know the height before.
Marcel
These plugins typically will take care of that.
Shawn Steward
A: 

Try making them visible just before using the jScrollPane plugin

$(".hidden").click(
{   
    $(this).css('display:block');
    $(this).jScrollPane();
});
Catfish
The correct syntax is `.css('display', 'block')` and you can just use `.show()` to get the same effect. :)
Tatu Ulmanen
yes i forgot that in my example, i was doing that before, thx - but i was looking for a way to make it work on "none" elements from the start ;)
Marcel
It has to change the display at some point, whether it does it in the plug-in or in your call doesn't really make a difference.
Shawn Steward