I have some JavaScript code that is supposed to run on document.ready but I keep getting an error in firebug saying the onLoad() method can’t be found.
Here is the code (which clearly shows that method there):
<script type="text/javascript">
var tl;
function onLoad1() {
debugger;
var eventSource = new Timeline.DefaultEventSource(0);
// Example of changing the theme from the defaults
// The default theme is defined in
// http://simile-widgets.googlecode.com/svn/timeline/tags/latest/src/webapp/api/scripts/themes.js
var theme = Timeline.ClassicTheme.create();
theme.event.bubble.width = 350;
theme.event.bubble.height = 300;
var d = Timeline.DateTime.parseGregorianDateTime("1900")
var bandInfos = [
Timeline.createBandInfo({
width: "80%",
intervalUnit: Timeline.DateTime.DECADE,
intervalPixels: 200,
eventSource: eventSource,
date: d,
theme: theme,
layout: 'original' // original, overview, detailed
}),
Timeline.createBandInfo({
width: "20%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 200,
eventSource: eventSource,
date: d,
theme: theme,
layout: 'overview' // original, overview, detailed
})
];
bandInfos[1].syncWith = 0;
bandInfos[1].highlight = true;
debugger;
tl = Timeline.create(document.getElementById("tl"), bandInfos, Timeline.HORIZONTAL);
// Adding the date to the url stops browser caching of data during testing or if
// the data source is a dynamic query...
var jsonFile = "<%= Url.Content("~/scripts/Views/Business/")%>test.js?"+ (new Date().getTime());
tl.loadJSON(jsonFile), function(json, url) {
eventSource.loadJSON(json, url);
});
}
var resizeTimerID = null;
function onResize() {
if (resizeTimerID == null) {
resizeTimerID = window.setTimeout(function() {
resizeTimerID = null;
tl.layout();
}, 500);
}
}
</script>
<script type="text/javascript">
$(document).ready(function() {
debugger;
onLoad1();
});
</script>
any idea why it can’t "find" that method.
EDIT
- I put all of the JavaScript above (removed the image).
- I renamed it
onLoad1()but I still got the same issue. - I moved the first code below the function but I still get the same issue.
You have a syntax error here:
You have to remove the closing parenthesis after the
jsonFileargument:This SyntaxError was breaking the function declaration, what’s why
onLoadwas not defined.