javascript - jCarousel not getting drawn inside a hidden div -
i using div populate ul/li list , draw jcarousel out of it. works fine:
$('#mycarousel').jcarousel();
here problem:
the div containing ul/li items hidden click of button. when div hidden, , re-size browser window, jcarousel attempts redraw itself, since hidden, not able draw properly. result jumbled in list (if click button again make visible). again if re-size window (the jumbled jcarousel not hidden now), redraws correctly.
i tried getting ahold of jcarousel instance , reload button clicked make div visible (the way re-sizes when visible , window re-sized).
to jcarousel, using:
jquery('#mycarousel').data('jcarousel')
and returned null.
how can jcarousel draw correctly?
what makes assume $().jcarousel()
call .data()
? better stick api provided plugin anyway, rather guessing @ how works under hood. anyway, answer question...
the problem that, when div hidden, has no height or width. use "off-left technique" rather hiding div, this:
#mycarousel { height: 100px; /* whatever height div have when shown */ width: 100px; /* whatever width div have when shown */ position: absolute: left: -10000px; }
when want show it, use $('#mycarousel').css('position', 'static')
remove absolute positioning, , div jump place.
a little more info here.
Comments
Post a Comment