Jquery Register Problem In Widget

Hi all,

I’d like to apply a jquery plugin in a list of news.

I created my widget to include this box in some page of mysite.

The problem is that in the page rendered, in the source code seems that the js file and script is loaded correctly but the plugin doesn’t work…


<script src="/juvebook/js/jquery.totemticker.min.js" type="text/javascript">

and the script too:


<script type="text/javascript">

/*<![CDATA[*/

$(document).ready(function(){

alert('ready');

alert($('head').html());

$('#vertical-ticker').totemticker();

});

/*]]>*/

</script>

This is the view file of my widget:


<?php 

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/jquery.totemticker.min.js', CClientScript::POS_HEAD); 

$js = "

    $(document).ready(function(){  

        alert('ready');

        $('#vertical-ticker').totemticker();

    });

";

Yii::app()->clientScript->registerScript('totemSlideNews', $js, CClientScript::POS_HEAD);

?>

<ul id="vertical-ticker">

<?php  

foreach($news as $currentNews)

{ ?>

    <li class="feednews">

        <div style="float:left; width:30%;">

            <p><?php echo $currentNews['datePubb']; ?></p>

            <p><?php echo $currentNews['header']; ?></p>

        </div>

        <div>

            <?php echo $currentNews['title']; ?>

        </div>

    </li>    

<?php } ?>

</ul>

So, the question is, can i include the js used only by a widget directly in his view file?

If yes why firebug, when i try to run by console the script say “$(”#vertical-ticker").totemticker is not a function", like if the library didn’t loaded?

Thank you

Bye

Mattia