Issue with load function

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?

Hello,
please use template functions in order to change html content of the events. The data seems to be redrawed after loading, and that rewrites your changes made directly in DOM.

The content of month event is defined by following template functions:

scheduler.templates.event_bar_date = function(start,end,ev) { return "• <b>"+scheduler.templates.event_date(start)+"</b> "; }; scheduler.templates.event_bar_text = function(start,end,ev){ return ev.text; };

So when the event is rendered, it receives content in following way: scheduler.templates.event_bar_date(event.start_date, event.end_date, event) + scheduler.templates.event_bar_text(event.start_date, event.end_date, event)

What you need to do, is to override the template functions as required:

scheduler.attachEvent("onTemplatesReady", function(){ scheduler.templates.event_bar_date = function(start,end,ev) { return "";//one of templates can be empty }; scheduler.templates.event_bar_text = function(start,end,ev){ return "custom HTML"; }; }); scheduler.init(....);
docs.dhtmlx.com/scheduler/api__s … plate.html
docs.dhtmlx.com/scheduler/api__s … plate.html
docs.dhtmlx.com/scheduler/month_ … lates.html

Ok this works fine, thanks, but I have a more general question. I need to retrieve all the events (or events in a specified pediod) on scheduler initialization (just after the data has been loaded from the db). I think “getEvents” is the right method, but when should I call it? Is there an event that fires just after the db loading is complete?
Thanks again!

You can try ‘onXLE’ event. However, a callback of “scheduler.load” should also work
docs.dhtmlx.com/scheduler/api__s … event.html

I think the real problem was another one.
I wrote all the configuration code for the scheduler in a “init()” function, just to call it in the “onload” event of the tag body. I think this is not correct. Maybe, an handler for the “onload” event is already attached to the scheduler, right.
Now I’m calling it in a script and it seems to work fine.