Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sails.js and foundation 6 - TypeError: url.indexOf is not a function

I am trying to use sails.js and Zurb Foundation 6.2. I used this handy npm generator that sets up my grunt tasks. The output looks pretty good. I have a single js file that contains jquery, foundation, etc.

In my layout.ejs, I have this:

<!DOCTYPE html>
<html>
  <head>
    <title><%=typeof title == 'undefined' ? 'New Sails App' : title%></title>

    <!-- Viewport mobile tag for sensible mobile support -->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <!--STYLES-->
    <link rel="stylesheet" href="/styles/app.css">
    <!--STYLES END-->

  </head>


  <body>
...  some html ...
    <%- body %>

    <!--SCRIPTS-->
    <script src="/js/dependencies/sails.io.js"></script>
    <script src="/js/dependencies/foundation.js"></script>
    <!--SCRIPTS END-->
     <script>
            $(document).foundation();
        </script>
  </body>

</html>

When I run the page, I get this error:

**TypeError: url.indexOf is not a function
jQuery.fn.load()
 foundation.js:9612
<anonymous>
 foundation.js:11913
<anonymous>**

My reading on this suggests that the issue is either that something is not be loaded, is being loaded more than once, or is in the wrong order. How do I narrow that down? I tried to use CDN's for each piece and still couldn't make it work.

Thank you for your help.

like image 548
Matt Knight Avatar asked Jun 16 '16 02:06

Matt Knight


People also ask

How to fix “uncaught TypeError a indexOf is not a function” error?

I was using jquery.poptrox.min.jsfor image popping and zooming and I received an error which said: “Uncaught TypeError: a.indexOf is not a function”error. This is because indexOfwas not supported in 3.3.1/jquery.min.jsso a simple fix to this is to change it to an old version 2.1.0/jquery.min.js.

Why is indexOf not working in jQuery?

This is because indexOfwas not supported in 3.3.1/jquery.min.jsso a simple fix to this is to change it to an old version 2.1.0/jquery.min.js. This fixed it for me. Share Follow edited Feb 12 '20 at 19:12

Is STR indexOf not a function?

const str = 1234; // ⛔️ Uncaught TypeError: str.indexOf is not a function const result = str.indexOf('3'); We called the indexOf method on a number which caused the error. The indexOf method is only supported on strings and arrays.


1 Answers

Foundation is not currently compatible with jQuery 3.0.0, Foundation is using the deprecated jQuery.fn.load(). Use jQuery 2.2.x for now. See issue and PR:

https://github.com/zurb/foundation-sites/issues/8834

https://github.com/zurb/foundation-sites/pull/8923

like image 194
d_rail Avatar answered Dec 29 '22 02:12

d_rail