CJuiButton
鍖 | zii.widgets.jui |
---|---|
缁ф壙 | class CJuiButton » CJuiInputWidget » CJuiWidget » CWidget » CBaseController » CComponent |
婧愯嚜 | 1.1.3 |
鐗堟湰 | $Id: CJuiButton.php 2799 2011-01-01 19:31:13Z qiang.xue $ |
婧愮爜 | framework/zii/widgets/jui/CJuiButton.php |
CJuiButton鏄剧ず涓涓寜閽儴浠躲
CJuiButton灏佽浜JUI Button 鎻掍欢銆
浣跨敤杩欎釜閮ㄤ欢褰撲綔涓涓彁浜ゆ寜閽紝浣犲彲浠ュ湪瑙嗗浘閲岄潰鎻掑叆浠ヤ笅浠g爜锛
浣跨敤杩欎釜閮ㄤ欢褰撲綔涓涓寜閽紝浣犲彲浠ュ湪瑙嗗浘閲岄潰鎻掑叆浠ヤ笅浠g爜锛
閫氳繃閰嶇疆options灞炴э紝 浣犲彲浠ユ寚瀹氶渶瑕佷紶閫掔粰JUI button鎻掍欢鐨勯夐」銆 濡傛灉闇瑕侀夋嫨锛坣ame-value pairs锛夛紝 璇峰弬闃JUI Button璇存槑銆
CJuiButton灏佽浜JUI Button 鎻掍欢銆
浣跨敤杩欎釜閮ㄤ欢褰撲綔涓涓彁浜ゆ寜閽紝浣犲彲浠ュ湪瑙嗗浘閲岄潰鎻掑叆浠ヤ笅浠g爜锛
$this->widget('zii.widgets.jui.CJuiButton', array( 'name'=>'submit', 'caption'=>'Save', 'options'=>array( 'onclick'=>'js:function(){alert("Yes");}', ), ));
浣跨敤杩欎釜閮ㄤ欢褰撲綔涓涓寜閽紝浣犲彲浠ュ湪瑙嗗浘閲岄潰鎻掑叆浠ヤ笅浠g爜锛
$this->widget('zii.widgets.jui.CJuiButton', array( 'name'=>'button', 'caption'=>'Save', 'value'=>'asd', 'onclick'=>'js:function(){alert("Save button clicked"); this.blur(); return false;}', ) );
閫氳繃閰嶇疆options灞炴э紝 浣犲彲浠ユ寚瀹氶渶瑕佷紶閫掔粰JUI button鎻掍欢鐨勯夐」銆 濡傛灉闇瑕侀夋嫨锛坣ame-value pairs锛夛紝 璇峰弬闃JUI Button璇存槑銆
鍏叡灞炴
灞炴 | 绫诲瀷 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|---|
actionPrefix | string | actions鐨処D鐨勫墠缂銆 褰撳井浠跺湪CController::actions涓0鏄庝簡 鍔ㄤ綔鎻愪緵鑰咃紝鍙互涓哄叾鍔ㄤ綔鐨処D鎸囧畾鍓嶇紑浠ュ尯鍒 浜庡埆鐨勫井浠舵垨鎺у埗鍣ㄣ傚綋寰欢鐢ㄤ簬鎺у埗鍣 鐨勮鍥句腑鏃讹紝蹇呴』閰嶇疆鍚屾牱鐨勫墠缂銆 | CWidget |
attribute | string | 鍜岃繖涓皬鐗╀欢鐩稿叧鐨勫睘鎬с 杩欎釜鍚嶇О鍙兘鍖呭惈涓嫭鍙凤紙渚嬪鈥榥ame[1]鈥欙級锛岀敤浜庢悳闆嗚〃鏍煎紡鐨勬暟鎹緭鍏ャ | CJuiInputWidget |
buttonType | string | 鎸夐挳绫诲瀷锛堝彲鑳界殑绫诲瀷锛歴ubmit锛宐utton锛宭ink锛宺adio锛宑heckbox锛宐uttonset锛夈 鈥渟ubmit鈥濇槸榛樿浣跨敤鐨勩 | CJuiButton |
caption | string | 鎸夐挳鐨勬枃鏈 | CJuiButton |
controller | CController | 杩斿洖姝ゅ井浠舵墍灞炵殑鎺у埗鍣ㄣ | CWidget |
cssFile | mixed | 涓婚鐨凜SS鏂囦欢鍚嶃傞粯璁ゆ槸鈥榡query-ui. | CJuiWidget |
htmlOptions | array | JUI缁勪欢涓璈TML鏍囩鐨勫睘鎬ц缃 | CJuiWidget |
htmlTag | string | buttonset鐨勯粯璁ゆ爣绛 | CJuiButton |
id | string | 杩斿洖姝ゅ井浠剁殑ID銆傚鏋滈渶瑕佺殑璇濓紝灏嗙敓浜т竴涓柊鐨処D骞跺皢鍏惰繑鍥炪 | CWidget |
model | CModel | 涓庤繖涓皬鐗╀欢鐩稿叧鐨勬暟鎹ā鍨 | CJuiInputWidget |
name | string | 杈撳叆妗嗗悕绉般傚鏋model娌℃湁璁剧疆锛岃繖涓繀椤昏缃 | CJuiInputWidget |
onclick | string | 杩欎釜椤硅鐐瑰嚮鏃跺紩鍙戠殑javascript鍑芥暟锛堝鎴风浜嬩欢锛夈 | CJuiButton |
options | array | the 鍒濆鐨凧avaScript闇瑕佷紶閫掔粰JUI鎻掍欢鐨勯夐」銆 | CJuiWidget |
owner | CBaseController | 杩斿洖姝ゅ井浠剁殑鎵鏈夎呮垨鍒涘缓鑰呫 | CWidget |
scriptFile | mixed | 涓昏JUI鐨凧avaScript鐨勬枃浠跺悕銆傞粯璁ゆ槸鈥榡query-ui. | CJuiWidget |
scriptUrl | string | 鍖呭惈鎵鏈塉UI JavaScript鏂囦欢鐨勬牴鐩綍銆 濡傛灉娌℃湁璁剧疆杩欎釜灞炴э紙榛樿锛夛紝Yii will publish the JUI package included in the zii release and use that to infer the root script URL. | CJuiWidget |
skin | mixed | 寰欢浣跨敤鐨勭毊鑲ょ殑鍚嶇О銆傞粯璁や负鈥渄efault鈥濄 濡傛灉姝ゅ睘鎬ц缃负false锛屽井浠跺皢涓嶄細鏈夌毊鑲よ浣跨敤銆 | CWidget |
theme | string | JUI涓婚鐨勫悕瀛椼傞粯璁ゆ槸鈥榖ase鈥欍傜‘淇濆湪themeUrl涓嬫湁杩欐牱涓涓洰褰曪紝 鍏跺悕绉版槸杩欎釜灞炴х殑鍊肩浉鍚岋紙鍖哄垎澶у皬鍐欙級銆 | CJuiWidget |
themeUrl | string | 鍖呭惈鎵鏈塉UI鐨勪富棰樻枃浠跺す鐨勬牴鐩綍銆 濡傛灉娌℃湁璁剧疆杩欎釜灞炴э紙榛樿锛夛紝 Yii will publish the JUI package included in the zii release and use that to infer the root theme URL. | CJuiWidget |
url | string | 褰撲竴涓寜閽被鍨嬩负鈥渓ink鈥濊閫夋嫨鏃朵娇鐢ㄧ殑URL銆 | CJuiButton |
value | mixed | 褰撳墠椤圭殑鍊笺備粎鐢ㄤ簬鈥渞adio鈥濆拰鈥渃heckbox鈥 | CJuiButton |
viewPath | string | 杩斿洖鍖呭惈姝ゅ井浠舵墍闇鐨勮鍥炬枃浠剁殑璺緞銆 | CWidget |
鍏叡鏂规硶
鏂规硶 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|
__call() | 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 | CComponent |
__construct() | 鏋勯犲櫒銆 | CWidget |
__get() | 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 | CComponent |
__isset() | 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 | CComponent |
__set() | 璁剧疆涓涓粍浠剁殑灞炴у笺 | CComponent |
__unset() | 璁剧疆涓涓粍浠剁殑灞炴т负null銆 | CComponent |
actions() | 杩斿洖姝idget浣跨敤鐨勫姩浣滅殑鍒楄〃銆 | CWidget |
asa() | 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° | CComponent |
attachBehavior() | 闄勫姞涓涓涓哄埌缁勪欢銆 | CComponent |
attachBehaviors() | 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 | CComponent |
attachEventHandler() | 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 | CComponent |
beginCache() | Begins fragment caching. | CBaseController |
beginClip() | Begins recording a clip. | CBaseController |
beginContent() | Begins the rendering of content that is to be decorated by the specified view. | CBaseController |
beginWidget() | Creates a widget and executes it. | CBaseController |
canGetProperty() | 纭畾灞炴ф槸鍚﹀彲璇汇 | CComponent |
canSetProperty() | 纭畾灞炴ф槸鍚﹀彲鍐欍 | CComponent |
createWidget() | Creates a widget and initializes it. | CBaseController |
detachBehavior() | 浠庣粍浠朵腑鍒嗙涓涓涓恒 | CComponent |
detachBehaviors() | 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 | CComponent |
detachEventHandler() | 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 | CComponent |
disableBehavior() | 绂佺敤涓涓檮鍔犺涓恒 | CComponent |
disableBehaviors() | 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 | CComponent |
enableBehavior() | 鍚敤涓涓檮鍔犺涓恒 | CComponent |
enableBehaviors() | 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 | CComponent |
endCache() | Ends fragment caching. | CBaseController |
endClip() | Ends recording a clip. | CBaseController |
endContent() | Ends the rendering of content. | CBaseController |
endWidget() | Ends the execution of the named widget. | CBaseController |
evaluateExpression() | 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 | CComponent |
getController() | 杩斿洖姝ゅ井浠舵墍灞炵殑鎺у埗鍣ㄣ | CWidget |
getEventHandlers() | 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 | CComponent |
getId() | 杩斿洖姝ゅ井浠剁殑ID銆傚鏋滈渶瑕佺殑璇濓紝灏嗙敓浜т竴涓柊鐨処D骞跺皢鍏惰繑鍥炪 | CWidget |
getOwner() | 杩斿洖姝ゅ井浠剁殑鎵鏈夎呮垨鍒涘缓鑰呫 | CWidget |
getViewFile() | 鏍规嵁瑙嗗浘鍚嶆煡鎵捐鍥炬枃浠躲 | CWidget |
getViewPath() | 杩斿洖鍖呭惈姝ゅ井浠舵墍闇鐨勮鍥炬枃浠剁殑璺緞銆 | CWidget |
hasEvent() | 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 | CComponent |
hasEventHandler() | 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 | CComponent |
hasProperty() | 纭畾灞炴ф槸鍚﹁瀹氫箟銆 | CComponent |
init() | (non-PHPdoc) | CJuiButton |
raiseEvent() | 鍙戣捣涓涓簨浠躲 | CComponent |
render() | 娓叉煋涓涓鍥俱 | CWidget |
renderFile() | Renders a view file. | CBaseController |
renderInternal() | Renders a view file. | CBaseController |
run() | (non-PHPdoc) | CJuiButton |
setId() | 璁剧疆姝ゅ井浠剁殑ID銆 | CWidget |
widget() | Creates a widget and executes it. | CBaseController |
鍙椾繚鎶ゆ柟娉
鏂规硶 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|
hasModel() | 纭畾鏄惁杩欎釜灏忕墿浠朵笌涓涓暟鎹ā鍨嬬浉鍏炽 | CJuiInputWidget |
registerCoreScripts() | 娉ㄥ唽鏍稿績鐨勮剼鏈枃浠躲 | CJuiWidget |
registerScriptFile() | 娉ㄥ唽涓涓狫avaScript鏂囦欢鍦scriptUrl涓嬨 | CJuiWidget |
resolveNameID() | CJuiInputWidget | |
resolvePackagePath() | 纭畾JUI鍖呭畨瑁呰矾寰勩 | CJuiWidget |
灞炴ц缁
buttonType
灞炴
public string $buttonType;
鎸夐挳绫诲瀷锛堝彲鑳界殑绫诲瀷锛歴ubmit锛宐utton锛宭ink锛宺adio锛宑heckbox锛宐uttonset锛夈 鈥渟ubmit鈥濇槸榛樿浣跨敤鐨勩
public string $caption;
鎸夐挳鐨勬枃鏈
htmlTag
灞炴
public string $htmlTag;
buttonset鐨勯粯璁ゆ爣绛
onclick
灞炴
public string $onclick;
杩欎釜椤硅鐐瑰嚮鏃跺紩鍙戠殑javascript鍑芥暟锛堝鎴风浜嬩欢锛夈
url
灞炴
public string $url;
褰撲竴涓寜閽被鍨嬩负鈥渓ink鈥濊閫夋嫨鏃朵娇鐢ㄧ殑URL銆
value
灞炴
public mixed $value;
褰撳墠椤圭殑鍊笺備粎鐢ㄤ簬鈥渞adio鈥濆拰鈥渃heckbox鈥
鏂规硶璇︾粏
init()
鏂规硶
public void init()
|
婧愮爜锛 framework/zii/widgets/jui/CJuiButton.php#87 (鏄剧ず)
public function init(){
parent::init();
if ($this->buttonType=='buttonset')
{
list($name,$id)=$this->resolveNameID();
if(isset($this->htmlOptions['id']))
$id=$this->htmlOptions['id'];
else
$this->htmlOptions['id']=$id;
if(isset($this->htmlOptions['name']))
$name=$this->htmlOptions['name'];
else
$this->htmlOptions['name']=$name;
echo CHtml::openTag($this->htmlTag, $this->htmlOptions);
}
}
(non-PHPdoc)
鍙傝
- framework/zii/widgets/jui/CJuiWidget::init()
run()
鏂规硶
public void run()
|
婧愮爜锛 framework/zii/widgets/jui/CJuiButton.php#110 (鏄剧ず)
public function run()
{
$cs = Yii::app()->getClientScript();
list($name,$id)=$this->resolveNameID();
if(isset($this->htmlOptions['id']))
$id=$this->htmlOptions['id'];
else
$this->htmlOptions['id']=$id;
if(isset($this->htmlOptions['name']))
$name=$this->htmlOptions['name'];
else
$this->htmlOptions['name']=$name;
if ($this->buttonType=='buttonset')
{
echo CHtml::closeTag($this->htmlTag);
$cs->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').buttonset();");
}
else
{
switch($this->buttonType)
{
case 'submit':
echo CHtml::submitButton($this->caption, $this->htmlOptions) . "\n";
break;
case 'button':
echo CHtml::htmlButton($this->caption, $this->htmlOptions) . "\n";
break;
case 'link':
echo CHtml::link($this->caption, $this->url, $this->htmlOptions) . "\n";
break;
case 'radio':
if ($this->hasModel())
{
echo CHtml::activeRadioButton($this->model, $this->attribute, $this->htmlOptions);
echo CHtml::label($this->caption, CHtml::activeId($this->model, $this->attribute)) . "\n";
}
else
{
echo CHtml::radioButton($name, $this->value, $this->htmlOptions);
echo CHtml::label($this->caption, $id) . "\n";
}
break;
case 'checkbox':
if ($this->hasModel())
{
echo CHtml::activeCheckbox($this->model, $this->attribute, $this->htmlOptions);
echo CHtml::label($this->caption, CHtml::activeId($this->model, $this->attribute)) . "\n";
}
else
{
echo CHtml::checkbox($name, $this->value, $this->htmlOptions);
echo CHtml::label($this->caption, $id) . "\n";
}
break;
default:
throw new CException(Yii::t('zii','The button type "{type}" is not supported.',array('{type}'=>$this->buttonType)));
}
$options=empty($this->options) ? '' : CJavaScript::encode($this->options);
if (isset($this->onclick))
{
if(strpos($this->onclick,'js:')!==0)
$this->onclick='js:'.$this->onclick;
$click = CJavaScript::encode($this->onclick);
$cs->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').button($options).click($click);");
}
else
{
$cs->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').button($options);");
}
}
}
(non-PHPdoc)
鍙傝
- framework/CWidget::run()