vodkabears / Remodal

No longer actively maintained.
http://vodkabears.github.io/remodal/
MIT License
2.76k stars 774 forks source link

Uncaught TypeError: Cannot read property 'open' of undefined #270

Open YingChen-dci opened 7 years ago

YingChen-dci commented 7 years ago

Hi, I am using 1.1.0 to implement modal window. However it keep showing the following error whenever I tried our code or the example code you provided on the README page. Does anyone has any suggestion??

Error: ** the error shows up when open modal window. Uncaught TypeError: Cannot read property 'open' of undefined

Code: HTML:

<div class="remodal" data-remodal-id="modal">
  <button data-remodal-action="close" class="remodal-close"></button>
  <p>
    Responsive, lightweight, fast, synchronized with CSS animations, fully customizable modal window plugin with declarative configuration and hash tracking.
  </p>
  <br>
  <button data-remodal-action="cancel" class="remodal-cancel">Cancel</button>
  <button data-remodal-action="confirm" class="remodal-confirm">OK</button>
</div>

JS:

    $(document).on("click", "#user-add-btn", function() {
        var modal = $('[data-remodal-id=modal]').remodal(option);
        modal.open();  <- error pointed here**
    });
dylanjt commented 7 years ago

+1, I'm running into the same issue.

panoply commented 7 years ago

+1 need a fix on this. Issue occurs when initialising Remodal with data-remodal-target attribute opposed to using href. Issue when using TurboLinks 5:

VM6680:2 Uncaught TypeError: Cannot read property 'open' of undefined at HTMLButtonElement.<anonymous> (<anonymous>:2:24907) at HTMLDocument.o (<anonymous>:2:10000) at HTMLDocument.i.proxy (<anonymous>:2:7525)

guithib commented 7 years ago

+1 I am facing the same error.

Here the console info for the remodal.min.js file:

Uncaught TypeError: Cannot read property 'open' of undefined
at HTMLAnchorElement.<anonymous> (remodal.min.js:756)
at HTMLDocument.dispatch (jquery.js?ver=1.11.3:4)
at HTMLDocument.r.handle (jquery.js?ver=1.11.3:4)

(anonymous) @ remodal.min.js:756
dispatch @ jquery.js?ver=1.11.3:4
r.handle @ jquery.js?ver=1.11.3:4

Does someone found a fix?

panoply commented 7 years ago

This issue occurs when using data-attribute to open Remodal. Issue was resolved opening by anchor href eg: <a href="#remodal">Open</a>.