Not able to refresh screen after update using CodeIgniter

I’m not able to automatically refresh the screen after an update in CodeIgniter.

The new color gets updated in the DB but I have to refresh the browser to see the new color.

In the delete ‘model’ function I was forced to ‘render’ which updated the screen.

Tried the same thing for the update but it doesn’t work.

Is there another way to refresh the screen after an update?

When I update my color field directly from the lightbox and it updates without refreshing.

I included the main code below.

Thanks,

David

Notes:

// codeigniter

// 1) views/event_model.php.tpl

.dhx_cal_event.event_red div, .dhx_cal_event_line.event_red{
background-color: red !important;
color: white !important;
}
.dhx_cal_event_clear.event_red{
color: white !important;
}

var event_color = [
{ key: ‘’, label: ‘Default’ },
{ key: ‘red’, label: ‘Red’ },
{ key: ‘blue’, label: ‘Blue’ },
{ key: ‘green’, label: ‘Green’ },
];

scheduler.templates.event_class=function(start, end, event){
if(event.color)
return “event_”+event.color;

    return "";                                           

};

// 2) models/event_model.php
function update($action){
$this->get_values($action);
if ($this->validate($action)){
if (!$this->color) {
$this->color = $this->get_event_color($this->event_type);
}
$this->case_num = format_cn($this->case_num);
$this->active = 1;
$this->db->update(“events”, $this, array(“event_id” => $action->get_id()));
$action->success();
// <<<<< I WAS FORCED TO PUT THIS IN DELETE BUT DOESNT WORK HERE IF I UNCOMMENT RENDER
// $connector->render();
}
}

function get_event_color($event_type) {
$event_colors = sess_get(‘setup’,‘event_colors’);
$event_colors_array = explode(’,’, $event_colors);
if ($event_colors_array) {
foreach ($event_colors_array as $event_color) {
$event_color_array = explode(’|’,$event_color);
if ($event_color_array[0] == $event_type) {
return $event_color_array[1];
}
}
}
}

function delete($action){

$this->db->update("events", array('active' => 0), array("event_id" => $action->get_id()));

$data = array(
    'user_id' => sess_get('user','user_id'),
    'event_id' => $action->get_id(),
    'action' => 'delete',
    'action_date' => date('Y-m-d H:i:s')
);
$this->db->insert('log', $data);

$action->success();
$connector->render();

}

You can add a code like next to the client side scheduler’s initialization

[code]var dp = new dataProcessor(“data/events.php”);
dp.init(scheduler);

//refresh data after saving
dp.attachEvent(“onAfterUpdate”, function(sid, action, tid, details){
if (action == “update”)
scheduler.load(“data.php”);
});
[/code]

Where data.php - the same url, which was used for the initial data loading

awesome thanks

-David

unfortunately it didn’t work

data gets updated but screen does not

-D

scheduler.load("/scheduler/data");

var dp = new dataProcessor("/scheduler/data");

dp.action_param =“dhx_editor_status”;

dp.init(scheduler);

dp.attachEvent(“onAfterUpdate”, function(sid, action, tid, tag){

 var message = tag.getAttribute("case_num");                  
 if (message) dhtmlx.message(message);                        
                                                              
 message = tag.getAttribute("event_name");                    
 if (message) dhtmlx.message(message);                        
                                                              
 message = tag.getAttribute("division");                      
 if (message) dhtmlx.message(message);                        
                                                              
 if (action == "update")                                      
     scheduler.load("/scheduler/data");                       

});

Call to scheduler.load must refresh data in the grid
Please try to use debug tools ( firebug or similar ones ) and double-check that request for data reloading was sent to server side and it returns a valid xml data.

By any chance, are you using dynamic loading mode in the scheduler ? ( as it may interfere with the data reloading code )