Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
Open modal using jquery?
Jackson last edited by
I’m trying to open the ons-modal in my page using jquery but I really don’t know why I’m getting the following error:
ReferenceError: modal is not defined
This is a working Fiddle with my code: https://jsfiddle.net/u3wy27s7/3/
And when i add ons.bootstrap(); to the top of my code, I get the following error:
TypeError: ons.bootstrap is not a function
Could someone please point me in the right direction?
Thanks in advance.
munsterlander 侍 last edited by munsterlander
@Jackson Check this fiddle: https://jsfiddle.net/u3wy27s7/4/
It is working now. Your modal used var instead of id. You do not need to call bootstrap. Onsen is loaded and working.
leneborma last edited by
The $(…).modal is not a function is usually caused because scripts are loaded in the wrong order . The browser will execute the scripts in the order it finds them. If in a script you attempt to access an element that hasn’t been reached yet then you will get an error. Make sure that you don’t have a script above one that it requires.
Multiple jQuery instances
Sometimes this warning may also be shown if jQuery is declared more than once in your code. The second jQuery declaration prevents bootstrap.js from working correctly. The problem is due to having jQuery instances more than one time. Take care if you are using many files with multiples instance of jQuery. Just leave one instance of jQuery and your code will work.