====== jQueryで非同期処理(DB更新) その2  ======
protocalendar.js を組み込んでみる。
http://labs.spookies.jp/product/protocalendar
===== テーブル作成  =====
CREATE TABLE IF NOT EXISTS `tasks` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created` datetime NOT NULL,
  PRIMARY KEY (`id`)
);
===== index.ctp  =====
  * protocalendar を使うために prototype.js を、非同期処理に jQuery を使っているが、共存には注意。
読み込む順番は prototype ⇒ jQuery、その直後に jQuery.noConflict() の記述が必要。
css('stylesheets/simple');
echo $html->script('prototype');
echo $html->script('protocalendar');
echo $html->script('jquery-1.3.2.min');
echo $html->script('jquery-ui-1.7.3.custom.min');
?>
Tasks
create('Task', array('default'=>false)); ?>
  
    
    
    
  
  
    
  
end(); ?>
===== ajax_add.ctp  =====
===== ajax.ctp  =====
===== tasks_controller.php  =====
set('tasks', $this->Task->find('all',array('order' => array('title'))));
    }
    function ajax_add() {
        $this->layout = "ajax";
        if($this->RequestHandler->isAjax()) {
            $title = $this->params['form']['title'];
            $this->Task->id = null;
            $this->data['Task']['title'] = $title;
            $this->Task->save($this->data);
            $this->set('t', $title);
        }
    }
}