0

I'm using the jQuery UI Layout plugin and I keep getting this error in Firebug: $('body').layout is not a function. I also get the same error in IE8 and below.

Obviously, it's being caused by the line where I initiate the layout UI in my scripts file:

$('body').layout({ *options here* });

Is there a way to prevent this error from showing? I'm pretty sure I need the BODY selector for this particular plugin to run.

** SOLUTION **

As the helpful answers say below, I had this line: $('body').layout({ *options here* }); BEFORE I included my jQuery and jQuery UI Layout Plugin files. Once I put the body.layout after those two inclusions, the error went away.

Daniel Li
  • 14,976
  • 6
  • 43
  • 60
FastTrack
  • 8,810
  • 14
  • 57
  • 78
  • 1
    Make sure you are including the jQuery layout plugin script into your page and that you are only including one copy of jquery. – Kevin B Aug 07 '12 at 15:16

2 Answers2

4

You seem to either

1) have not included the plugin properly (script tag missing/typo in the url, included it before loading jquery itself, whatever else could go wrong)

 or

2) calling $("body").layout too early - wrap it with $(document).ready(function() { });

it should be

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.layout.js"></script>

...

<script type="text/javascript">
   $(document).ready(function() {
      $("body").layout() // will work now
   });
</script>

Christoph
  • 50,121
  • 21
  • 99
  • 128
2

Make sure you're including the lines:

<SCRIPT type="text/javascript" src="/path/to/jquery-latest.js"></SCRIPT>
<SCRIPT type="text/javascript" src="/path/to/jquery.layout-latest.js"></SCRIPT>

Prior to the code you placed in your question. Otherwise, layout will have been undefined before use.

Daniel Li
  • 14,976
  • 6
  • 43
  • 60