hi, I’m using scheduler.load("/user/data", json), but it gets invalid date and I can´t figure out why.
It only shows the events from parse.
html:
<script src="https://cdn.dhtmlx.com/scheduler/edge/dhtmlxscheduler.js" charset="utf-8"></script>
<link rel="stylesheet" href="https://cdn.dhtmlx.com/scheduler/edge/dhtmlxscheduler_material.css" type="text/css" charset="utf-8">
</head>
<body onload="init();">
<% include ../layouts/layout.ejs %>
<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:80%;'>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button"> </div>
<div class="dhx_cal_next_button"> </div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab"></div>
<div class="dhx_cal_tab" name="week_tab"></div>
<div class="dhx_cal_tab" name="month_tab"></div>
</div>
<div class="dhx_cal_header"></div>
<div id = "ola_a" class="dhx_cal_data"></div>
</div>
</body>
<script type="text/javascript">
function init() {
scheduler.config.xml_date = "%Y-%m-%d %H:%i";
scheduler.config.first_hour = 8;
scheduler.config.last_hour = 22;
scheduler.config.dblclick_create = false;
scheduler.config.draggable = false;
scheduler.attachEvent("onTemplatesReady", function(){
scheduler.templates.event_text=function(start,end,event){
return "<b>" + event.text + "</b><br><i>" + event.type + "</b><br><i>" + event.location + "</i>";
}
});
scheduler.init("scheduler_here", new Date(2018, 9, 4), "week");
scheduler.parse([
{type:"PL", location: "1.2.21", text:"ITW", start_date:"2018/09/10 14:00", end_date:"2018/09/10 17:00"},
{type:"T", location: "3.1.14", text:"P-II", start_date:"2018/09/11 14:00", end_date:"2018/09/11 17:00"},
{type:"PL", location: "1.2.25", text:"BD", start_date:"2018/09/11 16:00", end_date:"2018/09/11 19:00"}
],"json");
scheduler.load("/user/data","json");
}
</script>
server side:
router.get('/horario', function (req, res) {
var e = new Data();
e.text = "BB";
e.start_date = new Date(2018,8,4, 10, 0);
e.end_date = new Date(2018,8,4, 12, 0);
e.save();
res.render('user/horario');
});
router.get('/data', function(req, res){
Data.find({text: "BB"}).exec(function(err,data){
for (var i = 0; i < data.length; i++) {
data[i].id = data[i]._id;
console.log(data[i].id);
}
//output response
res.send(data);
});
});