frocco
(Farocco)
1
Hello,
I want to call a php function in my controller and display a message on the page if the function returns true.
currently I am using javascript to just refresh the page, but this is causing the page to blink every 30 seconds.
I am using CListView to display the data if the function returns true.
how can I do this in Yii?
Thanks
frocco
(Farocco)
2
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
var refreshId = setInterval(function()
{
$('#responsecontainer').fadeOut("slow").load('http://localhost/mysite/site/index2').fadeIn("slow");
}, 10000);
</script>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$pendingOrders,
'itemView'=>'/site/_viewPending',
)); ?>
Above code is not refreshing the list
tri
(tri - Tommy Riboe)
3
I think this is the function you need to use
$.fn.yiiListView.update('yourListViewID');
(untested)
/Tommy
In controller or in the view?
You should create a little component: /protected/components/YourComponent.php with a static method:
class YourComponent {
public static function yourMethod () {
return true;
}
}
and call it in your controller:
if(YourComponent::yourMethod() == true) {
// do something
}
frocco
(Farocco)
5
Ok,
I got this working using
$.fn.yiiListView.update('pendingOrders');
$this->widget('zii.widgets.CListView', array(
'id'=>'pendingOrders',
'dataProvider'=>$pendingOrders,
'itemView'=>'/site/_viewPending',
'afterAjaxUpdate'=>'function(id,options){document.all.sound.src = "../notify.wav"; }',
));
I am having trouble calling a javascript function, not working.
Thanks