nyroModal icon indicating copy to clipboard operation
nyroModal copied to clipboard

TypeError: $(...).nyroModal is not a function

Open ghost opened this issue 9 years ago • 6 comments

My application in rails says me this error on firebug:

TypeError: $(...).nyroModal is not a function beforeShowCont: function() {

When I call Script.js: var width = 1152; var height = 864; $('.modal').nyroModal({ sizes: { initW: width, initH: height, minW: width, minH: height, w: width, h: height }, callbacks: { beforeShowCont: function() { width = $('.nyroModalCont').width(); height = $('.nyroModalCont').height(); $('.nyroModalCont iframe').css('width', width); $('.nyroModalCont iframe').css('height', height); } } });

I change "$('.modal').nyroModal({" to $(".nyroModal").nm({ but it doesn't works. What can I do?

Thanks.

ghost avatar Dec 16 '14 12:12 ghost

Did you load jQuery and complete nyroModal scripts BEFORE you load your script.js?

nyroDev avatar Feb 21 '15 15:02 nyroDev

Same error for me, using Jquery 1.9

Masadow avatar Mar 24 '15 13:03 Masadow

Did you load jQuery and complete nyroModal scripts BEFORE calling nyroModal? If so, could you provide a test page?

nyroDev avatar Mar 27 '15 12:03 nyroDev

For some obscure reason $.fn.extend is called after.

I guess what happen is

1- Page load 2- OnReady => Trigger an event 3- File included 4- My already resolved 5- Niro OnReady resolved

However, your plugin is the only one to crash with the scheme.

I can't provide an example because the app is too huge and we're using the plugin on a private page.

Masadow avatar Mar 27 '15 14:03 Masadow

Without an example or a way to reproduce the bug, I won't be able to fix it... Maybe you can create a JsFiddle to show it?

nyroDev avatar Apr 04 '15 11:04 nyroDev

I bumped into this same issue. In my case the problem was caused either by upgrading jQuery, or by putting jQuery into noconflict mode.

The problem is caused the way that the NyroModal functions are defined:

jQuery(function($, undefined) { ... });

These functions are executing after jQuery(document).ready(), which triggers the "$(...).nyroModal is not a function" warning.

I was able to resolve the error by replacing each instance of:

jQuery(function($, undefined) { ... });

with an anonymous function:

(function($) { ... })(jQuery);

Now those functions execute immediately instead of after document ready.

jnicol avatar Jun 01 '15 03:06 jnicol