I’m trying to run this simple code (using Pro trial version)
$(function() {
var $ganttDiv = $('.gantt'),
config = {
columns: [
{
name: 'name',
label: 'Task/Event',
resize: true
}
]
};
$ganttDiv.dhx_gantt(config);
$ganttDiv.each(function(index, element) {
var dataUrl = '/dashboard/schedule?id=' + $(element).data('id');
$(element).dhx_gantt().load(dataUrl);
});
});
Class .gantt has two divs, but only the second uses config. By debugging the plugin code, I see that this.gantt is undefined when I’m trying to run .load on first div element.
this code works fine:
[code]
};
$ganttDiv.dhx_gantt(config);
$ganttDiv.each(function(index, element) {
$(element).dhx_gantt(config);
[code]
but if I remove the first line, it fails again:
[code]
};
$ganttDiv.each(function(index, element) {
$(element).dhx_gantt(config);
[code]
this code works fine:
};
$ganttDiv.dhx_gantt(config);
$ganttDiv.each(function(index, element) {
$(element).dhx_gantt(config);
but if I remove the first line, it fails again:
};
$ganttDiv.each(function(index, element) {
$(element).dhx_gantt(config);
Hello,
we’ve confirmed a bug, when you create multiple gantts using jquery, the first one will be reset when you call $(element).dhx_gantt() on it’s element for the second time.
i.e.
[code]$(function() {
var first = $(“#gantt_here”).dhx_gantt();
var second = $("#gantt_here").dhx_gantt();
alert(first == second);// bug, second is a new instance, not a reference to the 'first'
var third = $("#gantt_here").dhx_gantt();
alert(second == third);// all correct, all subsequent calls will work correctly
alert(second == $("#gantt_here").dhx_gantt() && third == $("#gantt_here").dhx_gantt());// all correct, all subsequent calls will work correctly
});[/code]
Please try the updated package from the attachment, it should be corrected there
dhtmlxGantt_v4.0.5_evaluation.zip (1.33 MB)