Text 1 Aug 53 notes jQuery can’t get some properties from a hidden element

Today I founded an error with a plugin called Stylish Select (for customized selects). My select was contained in a hidden content (for filtering searches) and the plugin didn’t customize correctly my combo element. Its height was 0. And what’s the problem?, all its calculated operations are wrong. What’s the solution?, simply. Just find that hidden element (respect a concrete element):

var elToShow = $(this).parents(":hidden:last");
And show it:
if (elToShow.html() != null && elToShow.html().trim()){ // not empty
        var hideElement = 1;
        elToShow.show();
  		}
Calculate all its dimensions and immediately, hide it again:
if (hideElement) elToShow.hide();
And that’s all. P.S.: I forked my own version of that plugin. You can download it, here.

  1. rabarroso posted this

Design crafted by Prashanth Kamalakanthan. Powered by Tumblr.