Materialize: openModal() -> modal('open') broken in 0.97.8

Created on 2 Nov 2016  路  6Comments  路  Source: Dogfalo/materialize

I was using openModal() in 0.97.7 and it was working great. Inadvertantly upgraded to 0.97.8 and it broke. I checked the documentation and it looks like the method was changed to 'modal('open')', but this syntax doesn't work either. By changing to the new syntax, I no longer get the "openModal is not a function" error, but nothing happens.

Most helpful comment

Yep, was getting the same error, when I realized that they changed methods in a way, that .modal('open') not initializing as it was with modalOpen(), so you have to .modal() it first, apparently. The problem is, that they forgot to mention that in the docs and only changed the syntax. Right now it's understood that it's only necessary to init modals to hook it to a trigger, like in the old version.

All 6 comments

It works here: http://codepen.io/anon/pen/ZBzYwB
(check the second button)

Btw.: @Dogfalo the CodePen should be updated to the current version. :smiley:

Yep, was getting the same error, when I realized that they changed methods in a way, that .modal('open') not initializing as it was with modalOpen(), so you have to .modal() it first, apparently. The problem is, that they forgot to mention that in the docs and only changed the syntax. Right now it's understood that it's only necessary to init modals to hook it to a trigger, like in the old version.

Thanks for the responses guys. @Thanood, yes that works. It's a little weird that you're/they're initializing the modal by selecting its class, and then opening it with its id. I guess maybe to initialize multiple modals at the same time? Yea, I totally missed the initialize concept in the Docs, though I must say it's a little cryptic.

More like multiple triggers for the same modal.. :smiley:

It's not needed to initialize by class, btw. Just any selector that matches something. The href attribute on a link must be the same as the modal id. If you prefer buttons, you should be able to get away without using any IDs. IMO that's an improvement. :smiley:

Rgr, thanks!

@Thanood thanks, it's working for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hartwork picture hartwork  路  3Comments

bradley-varol picture bradley-varol  路  3Comments

lpgeiger picture lpgeiger  路  3Comments

onigetoc picture onigetoc  路  3Comments

ericlormul picture ericlormul  路  3Comments