Materialize: Materialbox not working if Image is loaded dynamically

Created on 27 Sep 2016  路  4Comments  路  Source: Dogfalo/materialize

Materialbox doesn't work for me when I am trying to load the image dynamically using ajax call. When I hard code the image then it works flawlessly.

Any help is really appreciated.
Thanks!

Most helpful comment

Fixed it. As the ajax call completes, i loaded the image in the DOM and then reinitialized .materialbox using this $('.materialboxed').materialbox();

Hope this helps others.
Thanks Materializecss team for providing such an awesome framework. :smile:

All 4 comments

Fixed it. As the ajax call completes, i loaded the image in the DOM and then reinitialized .materialbox using this $('.materialboxed').materialbox();

Hope this helps others.
Thanks Materializecss team for providing such an awesome framework. :smile:

Do you have an example of your code? Please

Can you please explain further. Am having the same issue wether images are loaded dynamically or hard coded

I ran into this same issue and I've try putting $('.materialboxed').materialbox(); at the end of my ajax call but that didn't work so I try the below code and it work. Notes: use the update() lifecycle

updated() {
            $('.materialboxed').materialbox();
        },

Hope this help someone who ran into the same issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

locomain picture locomain  路  3Comments

ruslandzhumaev picture ruslandzhumaev  路  3Comments

ReiiYuki picture ReiiYuki  路  3Comments

artur99 picture artur99  路  3Comments

alexknipfer picture alexknipfer  路  3Comments