Javascript error component not defined
tanc - February 2, 2009 - 21:19
| Project: | Timeline |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
I've installed the 6.x dev version on a working site and used the example view timeline_nodes to test. Everything appears to work up to the point where the ajax request is made and the json array is received. After this an error is thrown in Firebug:
var comps=(string.indexOf("T")==-1)?string.split(" "):string.split("T");
This error occurs on line 1376 of timeline.js
The returned json array looks healthy and many results are returned.
Any ideas on what may be causing this error and how to fix?

#1
After a Firefox restart I'm now encountering a completely different issue so I think the above issue may have been related to an older cached js file. The new issue is:
bandInfos[0].eventPainter.getLayout is not a function
bandInfos[1].eventPainter.setLayout(bandInfos[0].eventPainter.getLayout());in timeline.js
#2
Ok, I'm back to the original issue now. The eventPainter issue was because I'd updated from SVN which of course downloaded the new 2.0 branch code. I suggest altering your README file to include this line instead of the current svn command:
svn export http://simile-widgets.googlecode.com/svn/timeline/tags/1.2/src/webapp/api sites/all/modules/timeline/api#3
A bit more investigating reveals that the error is occurring in bundle.js rather than timeline.js and the error is related to the variable 'string' being undefined. Not sure what could be causing this issue though.
#4
Homing in on the issue now, it seems that views arguments are stuffing the view up. Not providing arguments doesn't help, the view itself needs to be modified to remove arguments otherwise the error mentioned above happens. I've confirmed this with the test timeline_nodes view, if I remove any argument handling code from the view (admin/build/views/edit/timeline_nodes) the view is presented perfectly with no js errors. I've also successfully created a custom view which works until arguments are added to the view code.
I'm pretty sure something is up with the json array returned by views. When I looked at the json callback results for a view which uses arguments (even though no arguments are added in the url) there appears to be an additional array added to the callback which I presume is messing with javascript. At the end of the additional array is this: /* !eval(new String('('+xmlhttp.responseText+');)) */Also, the second array is wrapped in brackets, unlike the first array. Why would a second array be returned which is almost identical to the first if argument handling code is added? Note that this happens for me with the default supplied test view timeline_nodes (until I deleted the argument code in the view).Edit - The above was just the way firebug was presenting the json array. Looking at the json result directly confirmed there were no issues.
#5
Me again. Ok, I think I've found the issue with argument handling in views. It looks like the latest views uses field aliases for the returned query result names and timeline doesn't support this properly. So my json query is returning empty (actually 1970) dates. To correct this I've had to patch the timeline.module and theme.inc files (attached). I don't think this is the cleanest way of doing this but may give you a head start. At least it allows for proper field aliases for views which use arguments.
#6
Thanks for taking such a thorough look at this. I'll review (and hopefully commit) this later in the week.
#7
I was also getting 1970 dates, and these patches worked for me. I hadn't run into any of the other problems Tanc described.
#8
this should be fixed with the 2.x branch of the module.