janwolniak / jsgantt

Automatically exported from code.google.com/p/jsgantt
0 stars 0 forks source link

'g' is not defined #125

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
SCRIPT5009: 'g' is not defined

You know what could be fixing this error?

Thank you for considering my request and I hope to hear back from you,

Original issue reported on code.google.com by gianlucc...@gmail.com on 10 Nov 2014 at 5:06

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Duplicate of Issue 91.

In both the documentation and the sample index file supplied by the jsgantt 
project the chart is instantiated with a command that stores the resulting 
gantt chart in a javascript variable "g" (line 93 in index.htm) i.e.

  var g = new JSGantt.GanttChart('g',document.getElementById('GanttChartDIV'), 'day');

Unfortunately there are multiple instances in the code where an assumption is 
made that the gantt chart object will always be stored in a variable named "g" 
(specifically lines 74, 75, 510, 512, 860, 877, 879, 923, 941, 943, 958, 970, 
and 972).  This means that if you use a different variable to store your gantt 
chart it just won't work i.e. if you instantiate the chart like this

  var myMeaningfulVariableName = new JSGantt.GanttChart('myMeaningfulVariableName',document.getElementById('GanttChartDIV'), 'day');

it will throw errors.

There are two work arounds.
1) always use a variable named "g" for your chart.
2) after instantiating the chart create a variable called "g" and set it to the 
variable name you used e.g.

  var myMeaningfulVariableName = new JSGantt.GanttChart('myMeaningfulVariableName',document.getElementById('GanttChartDIV'), 'day');
  var g = myMeaningfulVariableName;

Shameless plug: I've fixed this in my fork of jsgantt ( 
https://code.google.com/p/jsgantt-improved ) along with a lot of the other 
issues listed here.

Original comment by jsgantt.improved on 11 Dec 2014 at 8:36