Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic usage with react #97

Open
acollazomayer opened this issue Dec 12, 2018 · 1 comment
Open

Dynamic usage with react #97

acollazomayer opened this issue Dec 12, 2018 · 1 comment

Comments

@acollazomayer
Copy link

Hi, im trying to use this with react and react router. It is working fine when I reload the page. However when I enter to a page through an inside page link it stops working. I read that adding this:

getmdlSelect.init('select');

Might help with it. However the getmdlSelect function is not defined. I imported the js and the css.

@andyconlin
Copy link

Hi @acollazomayer, I just had the same issue (dynamic init, but not with react). If my assumption is correct, your css selector should refer to the the container div of the whole select sytem.

This worked for me:

getmdlSelect.init('.getmdl-select')

My implementation was essentially the example:

<!-- Simple Select with arrow -->
<div class="mdl-textfield mdl-js-textfield getmdl-select getmdl-select__fix-height">
  <input type="text" value="" class="mdl-textfield__input" id="cityName" readonly>
  <input type="hidden" value="" name="cityName">
  <i class="mdl-icon-toggle__label material-icons">keyboard_arrow_down</i>

  <ul id="cityNameUl" for="cityName" class="mdl-menu mdl-menu--bottom-left mdl-js-menu">
    <li class="mdl-menu__item" data-val="Boston">Boston</li>-->
    <!-- etc. -->
  </ul>
</div>

Hopefully you can get yours working, if it's still an issue for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants