goupviet / jsgantt

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

Create jsgantt object inside $(document).ready() #114

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I reproduced my project here: http://jsfiddle.net/Udkkv/4/ I cannot figure out 
why this is not working. I just copied example of jsgantt into my function 
createChartControl. Then I called this function from 
$(document).ready(function() {                      
                       createChartControl('schedule');
});
I spent a lot of time trying to figure out the problem, but still without 
success. Any help is highly appreciated.

Original issue reported on code.google.com by liana.na...@gmail.com on 11 Aug 2012 at 8:37

GoogleCodeExporter commented 9 years ago
http://jsfiddle.net/ult_combo/Udkkv/6/

Original comment by liana.na...@gmail.com on 11 Aug 2012 at 8:40

GoogleCodeExporter commented 9 years ago
I played around with it and it the order of orperation

if you change the first Dropdownlist under framework to  no wrap(body)

then remove under the javascript window
   function createChartControl(htmlDiv) {

   }

$(document).ready(function() {                      
    createChartControl('schedule');
});

so the javascript now has 
    var g = new JSGantt.GanttChart('g',document.getElementById('schedule'), 'day');

    g.setShowRes(1); // Show/Hide Responsible (0/1)
    g.setShowDur(1); // Show/Hide Duration (0/1)
    g.setShowComp(1); // Show/Hide % Complete(0/1)
    g.setCaptionType('Resource');  // Set to Show Caption (None,Caption,Resource,Duration,Complete)

        // Parameters             (pID, pName,                  pStart,      pEnd,        pColor,   pLink,          pMile, pRes,  pComp, pGroup, pParent, pOpen, pDepend, pCaption)

        g.AddTaskItem(new JSGantt.TaskItem(1,   'Define Chart API',     '',          '',          'ff0000', 'http://help.com', 0, 'Brian',     0, 1, 0, 1));

        //this line returns an error
        g.AddTaskItem(new JSGantt.TaskItem(11,  'Chart Object',         '7/20/2008', '7/20/2008', 'ff00ff', 'http://www.yahoo.com', 1, 'Shlomy',  100, 0, 1, 1));

        g.Draw();     
        g.DrawDependencies();

it will work

I hope that helps

Original comment by jacob.co...@iconfitness.com on 15 Aug 2012 at 4:36