[Edit 20090223: Ajout exemple avec invoke]
Exemple: Lien "Développer / Réduire au titre sur la page" d'accueil.
$$('.snippet').invoke('toggle');
ou itération manuelle:
function toggle_snippets()
{
var f = $$('.post-content');
for(var i=0; i < f.length; i++) {
f[i].toggle();
}
}
<?php /** * Form to add a classified ad. * * @author loic.vernet * @since 7 august 08 * * @package form */ class qbNewThreadForm extends qbThreadForm { // Default mask to create fields names public static $main_fields_name = 'qb_thread'; // Default labels protected $labels = array( // Thread 'title' => 'Sujet', 'category_id' => 'Forum', // Contact form 'qb_post' => 'Post', ); // Default fields to keep protected $fields_to_keep = array( // Thread 'id', 'category_id', // Post 'qb_post', ); // Liste of field that can't be modified by direct input values protected static $protected_fields = array( ); /** * Configuration of form. */ public function configure() { // Build widgets $this->setWidgetOptions(); // Set wdigets $this->processWidgets(); // Set validators $this->processValidators(); // Embed other forms $this->embedForms(); } /** * Set generic options for widgets. * * @author loic.vernet * @since */ protected function setWidgetOptions() { // name format $this->widgetSchema->setNameFormat(self::$main_fields_name. '[%s]'); // Set labels $this->setLabels($this->labels); // Allow extra fields for all forms $this->allowExtraFields(); } /** * set all widgets. * * @author loic.vernet * @since */ public function processWidgets() { $this->removeAllFieldsExcept($this->fields_to_keep); $this->widgetSchema['category_id'] = new sfWidgetFormPropelSelect( array( 'model' => 'qbCategory', 'add_empty' => false, //'criteria' => ipAdBasePeer::getCategoriesCriteria() )); $this->widgetSchema['title'] = new sfWidgetFormInput(); } /** * Set all validators. * * @author loic.vernet * @since */ public function processValidators() { $this->validatorSchema['category_id'] = new sfValidatorString( array('required' => true), array('required' => 'Veuillez choisir un forum') ); $this->validatorSchema['title'] = new sfValidatorString( array('required' => true), array('required' => 'Veuillez choisir un titre pour le sujet') ); } /** * Embed other forms to the current form. * * @author loic.vernet * @since */ protected function embedForms() { } }
var Fruit = Class.create(); Fruit.prototype = { initialize: function(fruit){ this.fruit = fruit; }, toString: function(){ return 'I am a fruit and my name is "' + this.fruit + '".'; } } var apple = new Fruit('apple'); $('fruits').update(apple); $('fruits').innerHTML; // -> 'I am a fruit and my name is "apple".'
class_exists('sfCache') or require_once($sf_symfony_lib_dir.'/cache/sfCache.class.php');
logs
8094.2 KB