JamesBarnsley
(Jamesbarnsleyfreelance)
November 26, 2010, 7:10pm
1
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?
ramin2nt2
(Ramin Mousavy)
November 26, 2010, 7:55pm
2
Yii::app()->clientScript->registerCoreScript('jquery');
$cs=Yii::app()->clientScript;
$cs->registerScriptFile(Yii::app()->baseUrl . 'file.js', CClientScript::POS_HEAD);
JamesBarnsley
(Jamesbarnsleyfreelance)
November 26, 2010, 11:50pm
3
Thanks, I guess does not have the hide, show etc, already programmed in then yeah?
JamesBarnsley
(Jamesbarnsleyfreelance)
November 27, 2010, 2:07pm
4
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?
ramin2nt2
(Ramin Mousavy)
November 27, 2010, 4:12pm
5
you could use fadeIn() fadeOut() and etc methods
JamesBarnsley
(Jamesbarnsleyfreelance)
November 27, 2010, 7:51pm
6
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?
twisted1919
(Serban Cristian)
November 27, 2010, 8:00pm
7
There’s no need for that. You have your jquery framework, you include a js containing your own animations and that’s all .
JamesBarnsley
(Jamesbarnsleyfreelance)
November 27, 2010, 9:45pm
8
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.
mdomba
(Maurizio Domba Cerin)
November 27, 2010, 10:02pm
9
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 …
JamesBarnsley
(Jamesbarnsleyfreelance)
November 27, 2010, 10:20pm
10
Thanks for clearing that up. So the functions I have asked have to be written in JQuery, I understand now.
meklop
(Alejandrofonseca)
December 12, 2011, 6:29am
11
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');
",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');
",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!
phtamas
(Phtamas)
December 12, 2011, 8:26am
12
Yii::app()->clientScript->registerCoreScript(‘jquery’) should be enough to include jQuery in your page.
Checklist:
Where to add this code. In views or in main index.php