Search code examples
reactjszurb-foundationzurb-foundation-6

React Component: Foundation Modal (Reveal) won't open


So I've just started learning React and Redux, so I apologize if this is a very noobish question. But I've emptied my Google quote, and can't find anything that helps me.

My problem is: I work on a site with React, Redux, and Foundation 6. One of my React components have a link, that when clicked, should open a Modal with a specific warning for that link. So I've created a component with my modal markup:

ComponentModal.js:

import React, { PropTypes } from 'react';
const Modal = () => (
  <div className="reveal" id="exampleModal1" data-reveal>
    <h1>Awesome. I Have It.</h1>
  </div>
);

export default Modal;

The component with a link renders some stuff, but basically have a

<a data-open="exampleModal1">Click me for a modal</a>

tag in it's render.

And although inspecting the page confirms that the markup for the modal exists, nothing happens when i click the link.
If I move the popup from the component, and into the DOM, the link works.
Some trial and error shows me, that if i manually run $(document).foundation(); in the console when ComponentModal is rendered, the popup works as intended.

So my question is kinda two questions: 1. How do I, in Redux, run $(document).foundation(); when my ComponentModal is done rendering? Maybe I'm wrong, but I don't have the componentDidMount() method available to me, where it might make sense to make that call? 2. Is this a totally wrong way to go about it?

Hope it's not too confusing and not too dumb a question :)


Solution

  • FYI, this question/solution has nothing to do with REDUX!

    The problem is that you're trying to use React AND Jquery to make your page do cool things.

    You should really choose one or the other.

    $(document).foundation() is a Jquery library.

    Instead you should use something like React Foundation which removes the jquery dependency and gives you foundation components built with react.