Yii Framework Forum: How To Include Core Script? - Yii Framework Forum

Jump to content

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

How To Include Core Script? Rate Topic: -----

#1 User is offline   Speeedfire 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 192
  • Joined: 02-March 12

Posted 30 April 2013 - 09:01 AM

class Controller extends CController
{

//code
	public function init() {
	    parent::init();
	    $cs=Yii::app()->clientScript;  
	    $cs->scriptMap = array(
		'jquery.js' => Yii::app()->request->baseUrl.'/js/jquery-2.0.0.min.js',
		'jquery.yii.js' => Yii::app()->request->baseUrl.'/js/jquery-2.0.0.min.js',
		'jquery.min.js' => Yii::app()->request->baseUrl.'/js/jquery-2.0.0.min.js',
		'jquery-ui.min.js' => Yii::app()->request->baseUrl.'/js/jquery-ui-1.10.2.custom.min.js',
		'jquery-ui-i18n.min.js' => Yii::app()->request->baseUrl.'/js/jquery-ui-i18n.min.js',
		'jquery-ui-i18n.min.js' => Yii::app()->request->baseUrl.'/js/jquery-ui-i18n.min.js',
		'jquery-ui.css'	=> Yii::app()->request->baseUrl.'/css/jquery-ui/redmond/jquery-ui-1.10.2.custom.min.css',
		'jquery-ui.min.css'	=> Yii::app()->request->baseUrl.'/css/jquery-ui/redmond/jquery-ui-1.10.2.custom.min.css'
	    );
	}
}

//another controller
class AnotherConroller extends Controller {
Yii::app()->getClientScript()->registerCoreScript('jquery');
Yii::app()->getClientScript()->registerCoreScript('jquery-ui.min.js');
Yii::app()->getClientScript()->registerCoreScript('jquery-ui.min.css');
}




Don't incule the scripts, why not? :blink:
0

#2 User is offline   Fabrizio Caldarelli 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 30 April 2013 - 09:09 AM

Try this:

//another controller
class AnotherConroller extends Controller {
Yii::app()->getClientScript()->registerScriptFile('jquery.js');
Yii::app()->getClientScript()->registerScriptFile('jquery-ui.min.js');
Yii::app()->getClientScript()->registerScriptFile('jquery-ui.min.css');
}

1

#3 User is offline   Speeedfire 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 192
  • Joined: 02-March 12

Posted 30 April 2013 - 09:20 AM

Thx it is work!
And what is the core script packages and how to include it?
e.g
Yii::app()->getClientScript()->registerCorePackage('jquery-ui');

View PostFabrizio Caldarelli, on 30 April 2013 - 09:09 AM, said:

Try this:

//another controller
class AnotherConroller extends Controller {
Yii::app()->getClientScript()->registerScriptFile('jquery.js');
Yii::app()->getClientScript()->registerScriptFile('jquery-ui.min.js');
Yii::app()->getClientScript()->registerScriptFile('jquery-ui.min.css');
}


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