germanysbestkeptsecret / Wookmark-jQuery

A jQuery plugin to create a dynamic, multi-column layout.
MIT License
2.63k stars 759 forks source link

Helpful hint - how to embed <li> into a tile #135

Closed ghost closed 10 years ago

ghost commented 10 years ago

I wanted to be able to use an unordered list within a tile, but the wookmark plugin was picking up all instances of "#tiles li" and rendering them as tiles, which broke the layout. I found a handy workaround, which is to exclude any li that is NOT of the id #tiles. I assigned my embedded li items id #inner, then called wookmark using the "not" function, like this:

  function applyLayout() {
    options.container.imagesLoaded(function() {

      // Create a new layout handler.
      handler = $('#tiles li:not("#inner")');

      // call wookmark layout
      handler.wookmark(options);

    });
  };

Hopefully this will save someone a bit of time.

Sebobo commented 10 years ago

Hi,

you shouldn't do that. ID's for elements should be absolutely unique or your html won't be valid.

Instead change your tile selector to just select the direct children of the #tiles:

handler = $('#tiles > li');
ghost commented 10 years ago

Even better, thanks!