From 1ed5d8c3f241116df31b92031ae18a2e6b5b3d4c Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 13 Dec 2005 15:14:38 +0000 Subject: Moved code for registering postback js from onPreRender to addAttributesToRender. It's too early to register js in onPreRender. --- framework/Web/UI/WebControls/TCheckBox.php | 31 ++++++++++++------------------ 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'framework/Web/UI/WebControls/TCheckBox.php') diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index ba3a45f7..2f51d8f5 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -50,13 +50,6 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl return 'input'; } - /** - */ - protected function addAttributesToRender($writer) - { - // TODO: add display inline block - } - /** * Loads user input data. * This method is primarly used by framework developers. @@ -108,9 +101,9 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl * Registers the checkbox to receive postback data during postback. * This is necessary because a checkbox if unchecked, when postback, * does not have direct mapping between post data and the checkbox name. - * + * * Auto-postback javascript code is also registered here. - * + * * This method overrides the parent implementation and is invoked before render. * @param mixed event parameter */ @@ -119,15 +112,6 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl parent::onPreRender($param); if($this->getEnabled(true)) $this->getPage()->registerRequiresPostData($this); - - if($this->getAutoPostBack() - && $this->getPage()->getClientSupportsJavaScript()) - { - $options = $this->getAutoPostBackOptions(); - $scripts = $this->getPage()->getClientScript(); - $postback = $scripts->getPostBackEventReference($this,'',$options,false); - $scripts->registerClientEvent($this, "click", $postback); - } } /** @@ -364,7 +348,16 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $writer->addAttribute('checked','checked'); if(!$this->getEnabled(true)) $writer->addAttribute('disabled','disabled'); + $page=$this->getPage(); + if($this->getAutoPostBack() && $page->getClientSupportsJavaScript()) + { + $options = $this->getAutoPostBackOptions(); + $scripts = $page->getClientScript(); + $postback = $scripts->getPostBackEventReference($this,'',$options,false); + $scripts->registerClientEvent($this, "click", $postback); + } + if(($accesskey=$this->getAccessKey())!=='') $writer->addAttribute('accesskey',$accesskey); if(($tabindex=$this->getTabIndex())>0) @@ -377,7 +370,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl /** * Sets the post back options for this textbox. - * @return TPostBackOptions + * @return TPostBackOptions */ protected function getAutoPostBackOptions() { -- cgit v1.2.3