I am working with Yii Jui widgets to have JuiTabs in a website. The problem is when the site is loading I first see the list (without any css) and then after the page loads the tabs show as they should. I wonder if there is a way to preload JuiTabs somehow so they show correctly when the page is loading.
Here is my code:
<?php
$this->widget('zii.widgets.jui.CJuiTabs', array(
'tabs'=>array(
'PRESENTAZIONE'=>array('content'=>$this->renderPartial('spettacoli/_view_presentazione', array('model'=>$model),$this)),
...
),
'options'=>array(
'collapsible'=>false,
),
));
?>
And here is the example of the page. The problem is visible when the internet connection is slow, and it takes time until the page loads
Not sure that's possible to preload JuiTabs somehow, but you can add display: none for CJuiTabs by default and show that with JS on page load. Not the best way, but first idea came into my mind.
Related
I have installed YiiBooster and am using the latest Yii v1.1.13. My main.php file contains the following configuration:
'preload'=>array('log','bootstrap'),
// application components
'components'=>array(
'bootstrap'=>array(
'class'=>'ext.bootstrap.components.Bootstrap',
'responsiveCss'=>true,
),
'user'=>array(
'class'=>'RWebUser',
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl'=> array('/user/login'),
),
...
However, after doing this none, of the YiiBooster widgets are displaying properly. As a new user I am not able to post images; however, my datepickerRow() widget looks just like the one in this post: Yii Booster datepicker not working correctly. The 'look' of the widget is not normal.
I have a number of other problems with other widgets. The bigger problem is the TbExtendedGridView that is not showing any of the View/Edit/Delete icons. Actually none of my 'prepend' icons are working on the forms either. Any ideas?
As requested - here is an example of a widget not working correctly. None of the little icons for view/edit/delete are shown. Also the row striping is not working, and the column title bar is a strange color.
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
'dataProvider'=>$dataProvider,
'type'=>'striped',
'columns'=>array(
'Registration',
'WONumber',
'InspectionType',
'LogEntryDate',
),
));
I am also having trouble with a textfieldRow() control. So I don't believe this is a problem with widgets, I think it is something to do with the way I have YiiBooster configured.
UPDATE - Still Not Working
I have found that the file in conflict with the CSS is the /var/www/intranet/css/screen.css file. When I remove this file from my main.php layout file, the CSS from YiiBooster works properly. The problem is that the rest of the page looks terrible.
So, I'm still researching why I can't run blueprint CSS and YiiBooster at the same time. Any help would be appreciated.
UPDATE - SOLVED
I found that other people were having trouble running the stock Yii blueprint CSS setup, so I switched completely over to YiiBooster and have not had any problems. I removed the CSS links in my main.php layout file. After converting all of the Yii widgets to YiiBooster widgets, everything works great.
You need to add the following to your grid as an element of the columns array:
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
'htmlOptions'=>array('style'=>'width: 50px'),
),
I don't know why my Captcha image do not refresh when i click on refresh link.
My code is :
<?php $this->widget('CCaptcha'); ?>
<?php echo $form->textField($model,'verifyCode'); ?>
I saw XHR response , it was empty and i checked the link of the refresh link , some thing like tis :
mydomain/captcha?refresh=1&_=1367673730496
and it return an image but it should return somthing like
{"hash1":311,"hash2":311,"url":"/mydomain/captcha?v=518509b295d06"}
I saw above link in the other application of mine which works fine with CCaptch.
On page refresh , Captcha image changes.
The corrupted captcha sent one XHR , the refresh one but the fine Captcha should send two as i saw in the other application,one for refresh and other for getting image.
What should i do ?
Edit:
I found another fact :
functional Captcha works with jquery.min but corrupted one works with jquery !! but i don't add anything to header , they added by Yii.
Second Edition:
I found two files which handle captcha in yii framework and i see when i send this request :
mydonmain/controller/captcha?refresh=1
And get
print_r($_GET);
die();
it return :
Array ( [/controller/captcha] => )
which means it don't understand get->refresh request !! somehow the $_GET request is disabled !!
Did you checked Yii main.php which contain urlManager section ? the rules are sequential.
if append to page the CGridView ('myGridViewID') by ajax, I can't reload it.
$.fn.yiiGridView.update('myGridViewID');
TypeError: settings is undefined
$grid.addClass(settings.loadingClass);
Use renderPartial in controller action:
$cs = Yii::app()->clientScript;
$cs->reset();
$cs->scriptMap = array(
'jquery.js' => false, // prevent produce jquery.js in additional javascript data
);
// Look at 4th parameter: with TRUE value, your view will have additional javascript data.
$this->renderPartial('_partialViewWithGrid', array(), false, true);
Here is a wiki for dynamic CgridViews in the same view. That should work.
The problem with dynamically loaded CGridViews (and everything containing ajax) is that CController::renderPartial() does not render the required javascript code for them to work properly, unlike CController::render(), which includes the required layout and JS.
There is an extension called ZController which offers a workaround for this problem, but due to the way CGridviews are reloaded (by making an ajax call to the same URL)... when you try to filter/sort/page a CGridView loaded via AJAX, the subsequent Ajax call will replace the whole contents of your browser window, but I honestly think that maybe (only maybe) this workaround could help, but I haven't had the time to try it out.
That is why I currently avoid loading CGridViews using AJAX.
This is my scenario. A home page with a upload form, user upload the images and submit, then the controller will catch the data from user, add it in the Model. Finally the image info will display in the another page.
I put the actionIndex() in the siteController to render the home page, the actionUpload() in the same file to handle the data user. So in the view, what should I put in the form action to invoke the actionUpload(). I think the flow is quite weird in Yii when I read the blog demo code, I just follow same way with the ASP.NET MVC. Suggest me the right way, plz. Thanks
Depends on how you build your form. If using CHtml, do the following:
<?= CHtml::beginForm($this->createUrl('site/upload'))?>
If you have a model that sits behind it:
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'login-form',
'action' => $this->createUrl('site/upload'),
)); ?>
Please check the Yii documentation and examples on how to properly set up forms. You have several choices here.
I am using yii framework. I want to hide pagination button of CListView widget but not disable them so that i can automatically trigger the request for next page by clicking them via javascript when user finish processing the list items. I tried enablePagination=>false but it remove the links to next pages too. I tried to hide them through javascript onLoad. Its working fine but in case the page load slowly I can see the pagination button.
Is there some standard way to hide them ?
You can use pagerCssClass property of CListView to define separate class for pagination button if i am getting your problem right.
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'template'=>"{items}\n{pager}",
'pagerCssClass'=>'hideButton',
));
CSS
.hideButton{
display:none;
}