I am new to meteor and jquery-layout.
I am struggling to see how to make the two work together. I have added the jquery and jquery-layout packages. I believe I need to ask jQuery layout to layout the page at some stage, but when? If I do it in the HTML page, I get the message "/ UI Layout Initialization Error / The center-pane element does not exist. /The center-pane is a required element.". I think this is because meteor hasn't yet loaded any templates. The example is based on a meteor default app. I added an extra template to go in the east pane. And pasted in the jQuery layout script.
So where, when and how should I layout my page?
<head>
<title>Layouts</title>
<script type="text/javascript">
$(document).ready(function () {
$('body').layout({ applyDemoStyles: true });
});
</script>
</head>
<body>
{{> navigation}}
{{> hello}}
</body>
<template name="navigation">
<div class="ui-layout-east">
<p>Navigation stuff here</p>
</div>
</template>
<template name="hello">
<div class="ui-layout-north">
<h1>Hello World!</h1>
{{greeting}}
<input type="button" value="Click" />
</div>
</template>
Actually the problem is just as the error says: the center pane is a required element. So instead of
ui-layout-east
andui-layout-north
, tryui-layout-east
andui-layout-center
:Also, the proper place to initialize the layout is within a template's
.rendered
event handler. So try restructuring your code such that there's one master template, such asroot
in the example below, and then put your jQuery initialization code insideTemplate.root.rendered
(line 2 of the .js file below). Don't put any JavaScript inside<head>
and don't use$(document).ready
:layout.html (assuming default filenames)
layout.js