I’m having inconsistent results with building my layout object using jquery-layout and jquery-ui libraries. When I bring up a page where the libraries are used as part of the ‘rendered’ function, sometimes it will build out, and sometimes not.
The specific modules I’ve added are that may have some bearing on this are:
jquery
jquery-layout
mizzao:jquery-ui
twbs:bootstrap
Below is an example of what I’m trying to do with a page that has the north/south/east/west divs setup as usual. Is there some special way of invoking the below code that would give me more consistent behavior?
Template.attributesPage.rendered = function () {
myLayout = $('.main').layout({
defaults: {
fxName: "slide"
, fxSpeed: "slow"
, spacing_closed: 14
, initClosed: false
},
west: {
minSize: 50
},
east: {
minSize: 200,
minHeight: 500
},
north: {
size: 210,
resizable: false,
closable: false,
spacing_open: 0,
spacing_close: 0
},
south: {
size: 43,
resizable: false,
closable: false,
spacing_open: 0,
spacing_close: 0
}
});
var templates = Templates.find();
var templateTreeArray = new Array();
templates.forEach(function (currTemplate) {
var templateTree =
{
'text': currTemplate.name,
'state': {
'opened': 'true',
'selected': 'false'
},
'children': new Array()
}
if (currTemplate.name == 'Conditions') {
var conditions = Conditions.find();
conditions.forEach(function (currCondition) {
var attributes = Attributes.findOne({'templateId': currCondition._id});
var condition = {
'text': currCondition.name,
'attId': attributes._id
}
templateTree.children.push(condition);
}); //conditions
} else if (currTemplate.name == 'Report Actions') {
var reports = ReportActions.find();
reports.forEach(function (currReport) {
var attributes = Attributes.findOne({'templateId': currReport._id});
var report = {
'text': currReport.name,
'attId': attributes._id
}
templateTree.children.push(report);
})
} else if (currTemplate.name == 'Report Specifications') {
var reportSpecs = ReportSpecifications.find();
reportSpecs.forEach(function (currReportSpec) {
var attributes = Attributes.findOne({'templateId': currReportSpec._id});
var reportSpec = {
'text': currReportSpec.name,
'attId': attributes._id
}
templateTree.children.push(reportSpec);
});
}
templateTreeArray.push(templateTree);
}); //templates
...