JQuery

Hi,

I noticed Yii encapsulates the GUI interface widgets for JQuery. Sliders, Accordian etc.

I also noticed it encapsulates Dragable, Dropable etc.

What about just standard effects though, like hide, show etc. What is the best way to use these in my Yii application?


Yii::app()->clientScript->registerCoreScript('jquery'); 

$cs=Yii::app()->clientScript;  

$cs->registerScriptFile(Yii::app()->baseUrl . 'file.js', CClientScript::POS_HEAD);  



Thanks, I guess does not have the hide, show etc, already programmed in then yeah?

I have been looking at the classes and I have not seen anything programmed into Yii, to do the show, hide functionality of JQuery. Even though I have seen selectable, droppable functionality programmed into Yii, is this true?

you could use fadeIn() fadeOut() and etc methods

Thank you for your help but I am not understanding.

What I am saying is that, Yii has the following JQuery encapsulation classes: -

CJuiAccordion

CJuiAutoComplete

CJuiButton

CJuiDatePicker

CJuiDialog

CJuiDraggable

CJuiDroppable

CJuiInputWidget

CJuiProgressBar

CJuiResizable

CJuiSelectable

CJuiSlider

CJuiSliderInput

CJuiSortable

CJuiTabs

CJuiWidget

Has Yii not encapsulated the "fadeIn" / "fadeOut" methods like it has done for many of the other JQuery functions?

There’s no need for that. You have your jquery framework, you include a js containing your own animations and that’s all .

Cheers, for your help everyone. Just needed that bit of reassurance, I also assumed it was easier just to do the methods in JQuery Javascript.

Yii encapsulates some jQuery plugins so that they can be called from PHP without messing with the js code…

fadeIn() and fadeOut() that you asked for are jQuery functions

Thanks for clearing that up. So the functions I have asked have to be written in JQuery, I understand now.

Hi all,

I still don’t understand what the purpose of Yii::app()->clientScript->registerCoreScript(‘jquery’) is.

I’ve got the following code:

<?php

Yii::app()->clientScript->registerCoreScript(‘jquery’);

[color="#0000FF"]Yii::app()->clientScript->registerScript(‘helloscript’,"

    alert('hello');


&quot;,CClientScript::POS_READY);[/color]

?>

… it doesn’t alert anything. But, if instead of registering the ‘jquery’ package I ‘registerScriptFile’ like the following:

<?php

$baseUrl = Yii::app()->baseUrl;

$cs = Yii::app()->getClientScript();

$cs->registerScriptFile($baseUrl.’/js/jquery-1.7.1.js’);

[color="#0000FF"]Yii::app()->clientScript->registerScript(‘helloscript’,"

    alert('hello');


&quot;,CClientScript::POS_READY);[/color]

?>

… I would get the wanted alert message.

So, my question is: why to register a ‘jquery’ package if the jQuery file has to be included anyway?

Thanks in advance!

Yii::app()->clientScript->registerCoreScript(‘jquery’) should be enough to include jQuery in your page.

Checklist:

  • Do you have a folder called "assets" in your webroot?

  • Is it writable by PHP?

  • Do you have any configuration for clientScript component that overrides defaults?

Where to add this code. In views or in main index.php