DEV Community

Discussion on: Materialize Modal closing instantly when attempting to load data from a URL

Collapse
 
ryansmith profile image
Ryan Smith • Edited

I think the answer lies in the browser dev tools, I suggest the following steps to help debug.

  • Before and after clicking the button, inspect the modal element in the DOM. Does its content change and is it your page's content? If it is, check to see that the modal's open class is still present, as it could be a styling or JavaScript toggling issue.
  • If the content remains the same, check the network tab. Is a network request to /ajax/editorModal.php showing up on button click?
  • If /ajax/editorModal.php is showing up in the network tab, is the request successful? You can also click on that request to view the Preview or Response that is being returned to ensure it is correct.
  • You can also try to separate this code out into a codesandbox/jsfiddle to see if it can be reproduced under isolated conditions. If it can, it is the code written. If it works fine, other code in your app may be impacting it. You can also post the link here for others to do some testing of it.
Collapse
 
tylerhs profile image
Tyler

Yes the network requests goes through, and the editorModal.php displays in the modal. The issue is, is that the modal won't even open half the time or it'll just close within 1-2 seconds.