Search code examples
javascriptjqueryprototypejs

How to solve TypeError iterator is not a function with prototypejs when jquery is is noconflict mode


I have designed a page where jquery works alongside other libraries like Prototypejs therefore i have put jquery in noconflict mode. However when I resize the window, firebug gives me the following notification

TypeError: iterator is not a function[Learn More] prototype.js:859:7 forEach self-hosted:265:9 each http://iusefaith.com/js/prototype/prototype.js:859:7 compressEvent http://iusefaith.com/design/design1/app/common/assets/js/cache/front-2017073101.min.js:6579:13 http://iusefaith.com/design/design1/app/common/assets/js/cache/front-2017073101.min.js:6575:1

I think I have put jquery in noConflict mode the right way. Here is my javascript code in no conflict mode

<!-- include javascript --> 
<!-- Placed at the end of the document so the pages load faster -->
<script  src="js/jquery/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$.noConflict();
</script>
...
<script src="js/prototype/prototype.js" type="text/javascript"></script>
 ...
<script src="design/design1/app/common/assets/js/cache/jquery-plugin-2017073101.min.js"></script>         

<script src="design/design1/app/common/assets/js/cache/front-2017073101.min.js"></script>

I am new to this type of error so please How to solve TypeError iterator is not a function with prototypejs when jquery is is noconflict mode ?


Solution

  • I think this is a very specific problem/bug in the resize javascript you are using but - this fixes your js error

    line 6579 of front.js in the compress method of windowResizeClass

    change the contents of the method from

        for (var k in windowResizer.resizeHandlers) {
            windowResizer.resizeHandlers[k]()
        }
    

    to

        windowResizer.resizeHandlers.each(function(item){
                item();
        });