Foundation-sites: [Sticky] failes to init and remove html markup

Created on 13 Feb 2016  ·  6Comments  ·  Source: foundation/foundation-sites

If I understood well the docs, I should be able to run sticky plugin from JS only, without extra markup in html like data-sticky-container or others.

I tried several times, still no luck, when initialized my

javascript 🐛bug

Most helpful comment

I experienced the same issue with 6.1.2 . It seems the problem is coming from this line : when you don't have a parent element with the data-sticky-container attribute, a container is created using the data-container template option/attribute. This container is created using the .wrapInner() jQuery function, but is never attached into the document tree.

Rewriting those lines as this seems to fix the problem (I'm too lazy to do a PR, sorry :sweat:)

if($parent.lenth){
  this.$container = $parent;
} else {
  this.wasWrapped = true;
  this.$element.wrap(this.options.container);
  this.$container = this.$element.parent();
}

All 6 comments

I experienced the same issue with 6.1.2 . It seems the problem is coming from this line : when you don't have a parent element with the data-sticky-container attribute, a container is created using the data-container template option/attribute. This container is created using the .wrapInner() jQuery function, but is never attached into the document tree.

Rewriting those lines as this seems to fix the problem (I'm too lazy to do a PR, sorry :sweat:)

if($parent.lenth){
  this.$container = $parent;
} else {
  this.wasWrapped = true;
  this.$element.wrap(this.options.container);
  this.$container = this.$element.parent();
}

This is still an issue with Foundation 6.2.1. This JS results in the #sidebar element disappearing from the markup entirely.

        var stickySidebar = new Foundation.Sticky($('#sidebar'), {
          // options…
        });

This appears to still be broken in 6.3.0. The fix from mlang38 fixed this for me.

Since the PR is merged, should this ticket be marked closed?

👍

Was this page helpful?
0 / 5 - 0 ratings