chidex77
(Osonwach)
1
Please, i will like to know how I can add JQuery code in my view file.
I will like to be able to type some Jquery functions directly into the view file without loosing
IDE code completion, syntax highlighting etc.
I once saw something like this:
<script>
$script = <<< JS
$(’#my_dropdown7’).mousedown(function(){
if($(this).options.length>
{
$(this).size=5;
}
alert(‘MOUSE DOWN !!!’);
});
</script>
Kindly help confirm the syntax and HOW & WHERE do i register the script !!
Thanks.
1 Like
hrnair
(Harikrishnan Hr)
2
chidex77
(Osonwach)
3
Thanks @hrnair,
But I didn’t get much from your link above
I needed guidance as to how to add Jquery like so:
<script>
$script = <<< JS
$(’#my_dropdown7’).mousedown(function(){
if($(this).options.length>
{
$(this).size=5;
}
alert(‘MOUSE DOWN !!!’);
});
JS;
</script>
<?php
//$this->registerJs($script, View::POS_END);
?>
Or Rather
Someone should please correct the above script !!
Thanks.
hrnair
(Harikrishnan Hr)
4
Hi,
$script = "$('#my_dropdown7').mousedown(function(){
if($(this).options.length><img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />
{
$(this).size=5;
}
alert('MOUSE DOWN !!!');
});"
just add $this->registerJs($script); POS_END is default.
See the source Html to see how this is rendered.
1 Like