Yii Framework Forum: Jquery Register Problem In Widget - Yii Framework Forum

Jump to content

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

Jquery Register Problem In Widget Rate Topic: -----

#1 User is offline   minitia 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 19-December 12

Posted 19 December 2012 - 10:28 AM

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
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