I’ve tried coding the options of CHtml::button in many many different ways, so that when I click on it, the current view would be refreshed, but I couldn’t succeed, so I’m asking for some help…
I’m using Yii 1.1.5.
Here is the last code I’ve tried with no success :
<?php echo CHtml::button('Réinitialiser', array('clientChange', array('click' => CController->refresh()))); ?>
Thanks in advance…
you can load content via ajax, or you can make refresh whole page. check window.location.reload
Actually I wanted to use the Yii refresh function because the effect of this method call is the same as user pressing the refresh button on the browser (without post data).
With window.location.reload the post data is sent along…
Hello ‘cher compatriote’
echo CHtml::htmlButton ('Refresh', array('onClick'=>'window.location="'.Yii::app()->getRequest()->getUrl().'"'));
Hi ‘voisin’ (I’m in Nice ),
No, clientchange can’t be use to attach event handler.
Look at its documentation, and the source code… With theses options, you can change the submit url, or add a “confirm”, or change the return value of the default ‘onclick’ event, but you can’t change the event itself.
You can only do that with classic ‘onclick’ html attribute, or by attaching your own event handler with some jQuery.
I used htmlButton instead of button, because the former will render a <button>, which is, imho, better than <input type=“submit”> when there’s no form submission…