Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Ken Brill on Sep 05, 2009 21:08
open dhtmlx forum
DHTMLScheduler - onEventAdded and onClick on the Month View

I have both of these events set up in my code and they work perfectly in the Day and Week views but not the Month view. All of my other events seem to be working in the Month view

Any Idea what I am doing wrong?



-----------------------------------------
<script type="text/javascript" charset="utf-8">
    function init() {
        scheduler.config.xml_date="%Y-%m-%d %H:%i";    
        scheduler.config.first_hour = 8;
        scheduler.config.last_hour = 18;    
        var sugar_calendar_date = Get_Cookie('sugar_calendar_date');
        var sugar_calendar_view = Get_Cookie('sugar_calendar_view');
        var myDate=new Date(sugar_calendar_date)

        scheduler.init('scheduler_here',myDate,sugar_calendar_view);
        scheduler.config.time_step = 15;
        //scheduler.setCurrentView(myDate, "month")
        scheduler.attachEvent("onEventAdded", function(event_id,event_object){
            //alert(event_id);
            //start_date
            //end_date
            //text
            //id
            //Wed Sep 02 2009 10:35:00 GMT-0500 (CST)
            //dumpProps(event_object);
            //alert(event_object.text)
            //window.open("index.php?module=Calendar&action=test&to_pdf=1")    
            window.location="index.php?module=Calendar&action=test&to_pdf=1&name="+event_object.text+"&start_date="+event_object.start_date+"&end_date="+event_object.end_date;        
});    
        scheduler.attachEvent("onViewChange", function (mode , date){
            Set_Cookie('sugar_calendar_view',mode,30,'/','','');
            Set_Cookie('sugar_calendar_date',date,30,'/','','');
        });
        
        scheduler.attachEvent("onClick", function (event_id, native_event_object){
            var type=event_id.substring(0,1);
            var id=event_id.substring(1);
            if(type=='c') {
                parent.window.location="index.php?return_module=Calendar&return_action=index&module=Calls&action=EditView&record="+id;
            }
            if(type=='m') {
                parent.window.location="index.php?return_module=Calendar&return_action=index&module=Meetings&action=EditView&record="+id;
            }
            return false;
        });
        
        scheduler.attachEvent("onEventChanged", function(event_id,event_object){
            //create data to send across
            postData = "index.php?to_pdf=1&module=Calendar&action=MoveEvent&start_date="+event_object.start_date+"&end_date="+event_object.end_date+"&record="+event_object.id;
//            //create callback function
            var callback =    {
                //on success, refresh list
                 success: function(o) {
                     //var targetdiv=document.getElementById('selected_directory_children');
                        //targetdiv.innerHTML=o.responseText;
                        //SUGAR.util.evalScript(o.responseText);
                        parent.ajaxStatus.flashStatus('Event Updated', 2000);
                 },
                 //do nothing on failure
                 failure: function(o) {/*failure handler code*/}
            };
//            //make ajax call
            var trobj = YAHOO.util.Connect.asyncRequest('GET',postData, callback, null);
        });
        
        scheduler.attachEvent("onXLE",function(){
         scheduler.render_view_data();
        });        
        
        scheduler.templates.event_header=function(start,end,event){
            return "<img src='themes/default/images/"+event.type+".gif' /><img src='themes/default/images/"+event.parent_type+".gif' />"+scheduler.templates.hour_scale(start);
        }
//        scheduler.templates.event_text=function(start,end,event){
//         return "<b><font color=blue>"+event.parent.substring(0,18)+"</font></b><br>"+event.text;
//        }        
        scheduler.load("cache/modules/Calendar/test.xml");
    }
Answer posted on Sep 07, 2009 03:14
>>but not the Month view
Both events are working in month view correctly. 
Attached sample is using the same code as was provided in your post and still both events are working in month view.( from code perspective - they must work for any mode ) 
Please beware that onclick event may skipped when you are clicking on custom images in event's header
Attachments (1)
Answer posted by Ken Brill on Sep 07, 2009 09:53
OK, Re-testing again today confirms what you said, it must have been a caching problem or something yesterday.  But on the Month view when creating a multiday event, is there a way to make is skip the lightbox and just run the 'onEventAdded' event?
Answer posted by Support on Sep 08, 2009 02:04
Can be done as
      scheduler.config.edit_on_create = false;