Giter Club home page Giter Club logo

Comments (10)

williamweckl avatar williamweckl commented on August 12, 2024 2

Solved it putting this code in my controller:

init: function () {
    this._super();
    Ember.run.schedule("afterRender",this,function() {
        $(document).foundation();
    });
},

from ember-cli-foundation-6-sass.

williamweckl avatar williamweckl commented on August 12, 2024

+1

from ember-cli-foundation-6-sass.

SlyDen avatar SlyDen commented on August 12, 2024

Or, e.g. I created wrapper component for content area like this:

// app/components/application-area.js

import Ember from 'ember';
export default Ember.Component.extend({
  didInsertElement() {
    this._super(...arguments);
    this.$().foundation();
  }
});

and app/templates/components/application-area.hbs contains just {{yield}}

from ember-cli-foundation-6-sass.

donaldwasserman avatar donaldwasserman commented on August 12, 2024

@GCheung55 @williamweckl Is this just a 2.5.x issue? have you updated to anything more recent?

from ember-cli-foundation-6-sass.

GCheung55 avatar GCheung55 commented on August 12, 2024

I ended up creating a wrapper component like @SlyDen's example. I don't think it was an issue with ember-cli v2.5.

I think this can be closed.

from ember-cli-foundation-6-sass.

joemcbroom avatar joemcbroom commented on August 12, 2024

@williamweckl

Solved it putting this code in my controller:

Where is the controller located?

from ember-cli-foundation-6-sass.

GCheung55 avatar GCheung55 commented on August 12, 2024

@Jumokee I think @williamweckl was referring to a controller that corresponded to the template that had needed the Foundation JS.

So you could create an application controller, or any of your routes can have a controller with the code.

from ember-cli-foundation-6-sass.

allthesignals avatar allthesignals commented on August 12, 2024

Thanks @williamweckl, I'm trying this in top-level application controller, and getting no luck. Ember does schedule it for afterRender, but it still seems to get called before those elements are in the DOM. Manually calling it in the console works just fine. Thoughts? Not sure why the Ember run loop isn't as intuitive as it seems... isn't afterRender a global event (as in, waits for everything to load, even children).

from ember-cli-foundation-6-sass.

allthesignals avatar allthesignals commented on August 12, 2024

Similar to @SlyDen, I just dropped a component initialize-foundation into the top-level application template, with the following hook inside the component:

  didRender: () => {
    $(document).foundation();
  }

This seems to work, until you render anything afterwards. You may have to do as @SlyDen does, but always wrap relevant foundation markup inside the component yield.

from ember-cli-foundation-6-sass.

SlyDen avatar SlyDen commented on August 12, 2024

As @allthesignals mentioned it won't work if you "add new HTML to the DOM" ... I faced with it recently.
I don't use addon nowadays, just raw Foundation 6.4.1. And I use only one or two Foundation's JS plugins - so I just call something like this in e.g. didInsertElement hook of my component:

Ember.run.schedule("afterRender", this, function() {
      this.$().foundation();
    });

Of course, it can be better solution than "afterRender" but it works without warnings ...

from ember-cli-foundation-6-sass.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.