Events not firing

Some of my template events aren’t firing as I would expect…
The day_event fires as expected, but the month_event_title and event_title don’t.

    // Event handler - Custom formatting for List calendar Activities
    scheduler.templates.event_title = function (obj, type) {
        return formatActivity(obj, type);
    };
    // Event handler - Custom formatting for Day calendar Activities
    scheduler.templates.day_event = function (obj, type) {
        return formatActivity(obj, type);
    };
    // Event handler - Custom formatting for Month calendar Activities
    scheduler.templates.month_event_title = function (obj, type) {
        return formatActivity(obj, type);
    };

I’ve also tried to hook into the following events and they never seem to fire.
// Event handler -
$$(“scheduler”).attachEvent(“onViewChange”, function (mode, date) {
dhx.alert(“onViewChange”);
});

        // Event handler -
        $$("scheduler").attachEvent("onBeforeMonthChange", function (b, arguments) {
            dhx.alert("onBeforeMonthChange");
        });

        // Event handler -
        $$("scheduler").attachEvent("onAfterMonthChange", function (b, arguments) {
            dhx.alert("onAfterMonthChange");
        });

BTW, is there a debug version of the dhtmlxscheduler_mobile.js script avaliable.

I would open a ticket on theses thing, but I’m still waiting for the PO to be processed. Hopefully tomorrow…

Thanks

Templates should be defined before scheduler initialization:
scheduler.templates.event_title = function(obj,type){
var html ="";
/your code here/
return html;
};
dhx.ready({
dhx.ui({
view: “scheduler”,
id: “scheduler”
});

});

Touch scheduler doesn’t call the same events as desktop version. You need to use events that are actual for Touch components. For example, you mau set onclick handler for the button with “list”, “day” and “month” segments:

$$(“scheduler”).$$(“buttons”).attachEvent(“onItemClick”,function(){
var view = this.getValue();
})

It can be used instead of onViewChange event.

Or the following can be set as on month change handler:
$$(“scheduler”).$$(“calendar”).attachEvent(“onAfterMonthChange”,function(date){

});

here are docs about elements of scheduler docs.dhtmlx.com/doku.php?id=dhtm … _scheduler

That helps with the scheduler events.

However, I still can’t get all my template events to fire correctly.
The strange thing is the scheduler.templates.day_event works, but none of the other do.

Any ideas on what I should look for or try.

Thanks again Jim

Show: function (e, ui) {
    // Enable Calendar Touch events
    dhx.Touch.enable();

    //Event handler - Navigate to the selected Activity
    scheduler.templates.selected_event = function (obj, type) {
        $.mobile.changePage(mobileApp.AppPath + "Activities/DetailAuid?auid=" + escape(obj.id), { transition: "pop" });
    };
    // Event handler - Custom formatting for List calendar Activities
    scheduler.templates.event_title = function (obj, type) {
        return formatActivity(obj, type);
    };
    // Event handler - Custom formatting for Day calendar Activities
    scheduler.templates.day_event = function (obj, type) {
        return formatActivity(obj, type);
    };
    // Event handler - Custom formatting for Month calendar Activities
    scheduler.templates.month_event_title = function (obj, type) {
        return formatActivity(obj, type);
    };

    scheduler.templates.event_date = function (date) {
        return dhx.Date.dateToStr("%m/%d/%y")(date);
    };

    //this.initEvents();
    this.setPreferences();

    // Can't add activities using calender 
    scheduler.config.readonly = true;

    //dhx.debug = true; // only turn on if debugging 

    dhx.ready(function () {
        dhx.ui.fullScreen();
        dhx.ui({
            container: "schedulerDiv",
            view: "scheduler",
            id: "scheduler"
        }, this);

Please check the ready “templates” sample in the scheduler:

dhtmlxScheduler_v30_111025/samples/07_mobile/04_templates.html

event_title is a template for item in event list. It includes time, date and event text. The same is for the month_event_title, but it doesn’t include date. So, probably day_event and event_title templates should be different.

Hi Alexandra:

Not sure I follow you on this.

What’s returned to the callback is determined by what is passed into the scheduler,
$$(“scheduler”).parse(data.responseText, “json”);

In “scheduler.templates.event_title = function(obj,type” the obj returns whatever was passed in the data.responseText. I don’t think content is the problem.

Regardless, the callback never fires so the obj content never comes into play.

Maybe I don’t understand something, as I’m new to working with this control.

I’t just seems very strange that scheduler.templates.day_event fires but the others don’t.

Something tells me that this could be a conflict with jquery mobile, but who knows.

I think at this point, I’ll open a ticket and see.

If you have any more suggestions please let me know.

and thanks for your help…

Jim

Hi,

what does formatActivity(obj, type) return ? Could you provide a ready sample ?

No problem:

Here’s the function…
// Helper - Format the List Activity
function formatDayActivity(obj, type) {
var html = “

” +
” +
” + obj.regarding + “” +
” + obj.duration + “” +
” + obj.contact + “”;
return html;
}

Here a sample thats returned:

Industry Trade Show01/18/2012 7:00 AM - 4 days 8 hours<Private Contact>

and another

Conference Call to answer initial project questions - Opportunity Name: "Green Plastics-LA Office" Process Name: "" Stage Name: "Presentation"01/18/2012 12:00 PM - 1 hour+Ben Braddock (Green Plastics)

The returned html successfully renders in the day view

Hope that helps…

here is the code that we tested - “List” view changed:

scheduler.templates.event_title = function (obj, type) {
return “

Industry Trade Show01/18/2012 7:00 AM - 4 days 8 hours<Private Contact>
}

dhx.ready(function(){
dhx.ui.fullScreen();
dhx.ui({
view: “scheduler”,
id: “scheduler”
});

Maybe it doesn’t like the container.

Can you try that?

dhx.ready(function () {
dhx.ui.fullScreen();
dhx.ui({
container: “schedulerDiv”,
view: “scheduler”,
id: “scheduler”
});

OK, looks like I need to do some more investigation on this.

container is not the problem

I’ll keep digging.

Thanks for your help