Démo d'installation scriptaculous / ajax / cake

download scriptaculous

scriptaculous et extraire

installer scriptaculous

copier tous les js dans cake/app/webroot/js

modifier layout.ctp

cake/app/views/layouts/layout.ctp

<head>
    <title>blabla</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<?php 
echo $javascript->link('prototype.js');
echo $javascript->link('scriptaculous.js?load=effects'); 
?>

modifier app_controller.php

cake/app/app_controller.php

ajouter entre les balises class:

// controller file
var $helpers = array('Html', 'Javascript', 'Ajax');
 
function view() {
    $this->render('layout file', 'ajax');
}

modifier la vue

ici j'ai pris cake/app/views/pages/home.ctp pour avoir ajax sur la homepage

<h2>Table remarques</h2>
<ul><li>
    <?php 
    #radeff: here a small example of using ajax / scriptaculous
    #see http://www.akademia.ch/dokuwiki/info:cake#scriptaculous
    echo $html->link('Remarques','#',array('onclick'=>'Effect.toggle("remarques", "blind", {duration: 0.2}); return false;')); 
   $event=array("Remarques"=>"remarques",
"Insérer une nouvelle remarques"=>"remarques/add"
);
    
    ?>
<sup>*</sup></li></ul>
<dl id="remarques" style="display:none;">
<?php foreach ($event as $lib=>$url): ?>
<dt><a href="<?php echo $url?>"><?php echo $lib; ?></a></dt>
<?php endforeach; ?>
</dl>            
                
 
info/scriptaculouscakeexemple1.txt · Dernière modification: 2009/12/04 15:54 (modification externe)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki