Widget For Flexslider

Hi everyone,

I’m trying to make a widget for FlexSlider, but it doesn’t work… Here’s what I got




<?php


	/**

	* Obtiene todos los enlaces activos

	*/

	class PublicidadWidget extends CWidget

	{

		private $_baseAssetsUrl;


		public function run()

		{

			$this->registerClientScript();


			$criteria = array('condition'=>'Estado = 1');

			$model = Publicidad::model()->findAll($criteria);


			$this->render('publicidad',array('model'=>$model));

		}


		public function registerClientScript()

		{

			$assets_path = dirname(__FILE__) .DIRECTORY_SEPARATOR. 'FlexSlider'.DIRECTORY_SEPARATOR;

			$this->_baseAssetsUrl = Yii::app()->assetManager->publish( $assets_path );


			$cs=Yii::app()->getClientScript();

			$cs->registerCoreScript('jquery');


			// Registrar script, css para flexslider

			$this->registerAsset('flexslider.css');

			$this->registerAsset('jquery.flexslider.js');


			$cs->registerScript(

			  'publicidad',

			  '$(window).load(function() {

			    $("#publicidad").flexslider();

			  });',

			  CClientScript::POS_READY

			);

		}


		/**

		 * generic function to register css or js

		 */

		protected function registerAsset($file)

		{

			$asset_path = $this->_baseAssetsUrl . '/' . $file;

			if(strpos($file, '.js') !== false)

				return Yii::app()->clientScript->registerScriptFile($asset_path);

			else if(strpos($file, '.css') !== false)

				return Yii::app()->clientScript->registerCssFile($asset_path);


			return $asset_path;

		}

	}


?>



Everything is register, but I cannot make the div “#publicidad” a flexSlider. This code is register but it seems that don’t do anything…




$cs->registerScript(

			  'publicidad',

			  '$(window).load(function() {

			    $("#publicidad").flexslider();

			  });',

			  CClientScript::POS_READY

			);



Hello, i have the same problem, when include the plugin flexslider, the library function correctly, but when add one grid, mark the same error, " TypeError: $(…).flexslider is not a function ", how include flexslider?, here code…

add the code css and js en two folders, one the leve to "css", and the other in "assets/assets/js",

I’m indicated the code as follows

In file MAIN.PHP




<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css/flexslider/flexslider.css" type="text/css" title="Estilo Menu CSS3" media="screen" />

<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/assets/assets/js/jquery.flexslider.js"></script>



after the code slider in file index.php




<div class="slider">

		<div class="flexslider">

		  <ul class="slides">

		    <li>

		      <img src="<?php echo Yii::app()->request->baseUrl; ?>/images/flexslider/slider1.jpg"/>

		    </li>

		    <li>

		      <img src="<?php echo Yii::app()->request->baseUrl; ?>/images/flexslider/slider2.jpg"/>

		    </li>

		    <li>

		      <img src="<?php echo Yii::app()->request->baseUrl; ?>/images/flexslider/slider3.jpg"/>

		    </li>

		    <li>

		      <img src="<?php echo Yii::app()->request->baseUrl; ?>/images/flexslider/slider4.jpg"/>

		    </li>

		  </ul>

		</div>

	</div>




The problem is to add the grid




<?php $this->widget('zii.widgets.grid.CGridView', array(

					'id'=>'boletin-grid',

					'dataProvider'=>$model->search(),

					'filter'=>$model,

					'columns'=>array(

						

						array(

							'class'=>'CButtonColumn',

						),

					),

				)); ?>