Returns dhtmlXPopup instance which was inited for tooltips (null if not inited or user not yet hover any cell with tooltip)
To be 100% sure that popup is inited when you call getPopup() we added onPopupShow event, it will fired every time tooltip becomes visible. You can attach ant content into it then.
var myPop = myCalendar.getPopup(); // we do not recommend use such constructions in your linear code // the best way if you plan to attach "heavy" content like grid // no needs to specify 2nd arg - text, only if "loading..." var lastDate = null; var myPop = null; var myGrid = null; myCalendar.setTooltip("2013-01-01", "<span style='font-style:italic;'>Loading...</span>", true, true); myCalendar.attachEvent("onPopupShow", function(date){ // save popup date if user will move mouse away while response go to server lastDate = this.getFormatedDate("%Y-%m-%d", date); // inside event handler 'this' points to myCalendar if any (applied to all dhtmlx) // load heavy content from server dhtmlxAjax.get("server.php?date="+lastDate, function(r){ // assuming server response was the following (in json format): // {state: true, date: "2013-01-01", gridConf: {...}} // 'date' param the same as was in request var t = null; try { eval("t="+r.xmlDoc.responseText); } catch(e){}; if (t != null && lastDate != null && t.state == true && lastDate == t.date) { if (!myPop) myPop = myCalendar.getPopup(); // we need it once myGrid = myPop.attachGrid(); myGrid.load(t.gridConf, "json"); // or something like } }); }); myCalendar.attachEvent("onPopupHide", function(){ if (myGrid != null) { myPop.clear(); // this will unload grid myGrid = null; } lastDate = null; // clear date, we will check it in callback (above) to be sure popup still visible });
Almost the same logic can be used to show popups over cells but instead of tooltips and onPopupShow you can use onMouseOver/onMouseOut events, init popup manualy and getCellDimension to determine cell x,y (where to show the popup), also you can skip grid reinit and just use grid.updateFromXML
See also: