Yii Framework Forum: Some thought for ZII dialog widget - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Some thought for ZII dialog widget Rate Topic: -----

#1 User is offline   monkeymon 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 07-July 09

Posted 02 November 2009 - 09:39 AM

I'm excited to see some native support for dialog widget but i find there will be error for "buttons" options as it will quote the function which make it not workable

here is my thought of modifications to the init function which will have it work again.
It might be the same as another JUI in the extensions sections

private function EncodeJavascript($script=array()) {
$returnVal = array();
if(is_array($script)) {
  foreach($script as $key=>$val) {
     $returnVal[] = "'".$key."':".$val;
  }
}
return '{'.implode(',',$returnVal).'}';
}


public function init() {
parent::init();
$button_array = '';
$id=$this->getId();
$this->htmlOptions['id']=$id;
//Added line 1
if(!empty($this->options['buttons'])) {
   $button_array = $this->options['buttons'];
   $this->options['buttons'] = 'NeedSpecialEncodeButtons';
}
$options=empty($this->options) ? '' : CJavaScript::encode($this->options);
//Added line 2
if(!empty($this->options['buttons'])) {
   $options = str_replace("'NeedSpecialEncodeButtons'",$this->EncodeJavascript($button_array),$options);
}
Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').dialog($options);");
echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
}

0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,892
  • Joined: 04-October 08
  • Location:DC, USA

Posted 02 November 2009 - 09:44 AM

Prefix a "js:" in front of the function definition to prevent it from being encoded.
0

#3 User is offline   monkeymon 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 07-July 09

Posted 02 November 2009 - 10:44 AM

View Postqiang, on 02 November 2009 - 09:44 AM, said:

Prefix a "js:" in front of the function definition to prevent it from being encoded.


wow never know that... learn a new thing again!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users