Hello,
I have an issue with the load function.
I’m tring to use the “getEvents” method in callback function but is not working fine.
It seems that the script loads the events twice.
Snippets:
this is my init() function
function init(userSelect,currentUser,isAdmin){
//scheduler config
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.config.multi_day = false;
scheduler.config.drag_create = true;
scheduler.config.details_on_create=true;
scheduler.config.year_x = 4; //2 months in a row
scheduler.config.year_y = 3; //3 months in a column
scheduler.config.scroll_hour = 13;
scheduler.init('scheduler_here', new Date(),"month");
scheduler.load("connector.action",function(){setMonthEventTitle();});
var dp = new dataProcessor("connector.action");
dp.init(scheduler);
var calendar = scheduler.renderCalendar({
container:"cal_here",
navigation:true,
handler:function(date){
scheduler.setCurrentView(date, "day");
}
});
//[...]
//other logic here
//[...]
function setMonthEventTitle(){
evs=scheduler.getEvents(scheduler.getState().min_date,scheduler.getState().max_date);
for (var i=0; i<evs.length; i++){
alert(evs[i].start_date);
ev_html=scheduler.getRenderedEvent(evs[i].id);
ev_html.innerHTML="custom HTML";
}
}
As you can see I want to replace the innerHTML of the loaded events with custom HTML. I made an alert for each loaded events.
The alert works fine, but the custom html doesn’t appear when I expected. More strange is that the entire cycle repeats 2 times, as if the function is called twice.
I’m loading data from mysql using java backend.
this is my connector.java
[code]@WebServlet(name=“Connector”, urlPatterns={"/connector.action"})
public class Connector extends ConnectorServlet {
private static final long serialVersionUID = -8819552090653981282L;
@Override
protected void configure() {
//obtain DB connection
Connection conn=null;
try {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection("jdbc:mysql://localhost/youtime", "root", "root");
} catch (Throwable e) {
e.printStackTrace();
}
//Initializes connector
SchedulerConnector c = new SchedulerConnector(conn);
//configures the used table and fields
c.render_table("events","id","start_date,end_date,text,userId,type");
}
}[/code]
Any idea or suggestion? Am I missing something?
Can someone explain clearly the way “load” function works?