Hide pagination button in CListView but donot disable them - yii

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;
}

Related

How to show or hide div on radiobuttonlist checked without jquery(if Javascript is disable) in asp.net mvc?

It works fine with jquery is there any way in mvc where I can fire an event on radiobuttonlist checked that executes server side code and can display or hide div accordingly, thanks in advance/

Yii - reload dynamically added CGridView

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.

:remote => true/data-remote on a form loaded via ajax

In my Rails app, I have a form that is loaded via Ajax using jQuery load method.
function load_sales_form(product_id) {
$("#sales_form").load("<%= url_for(:action => :show_sales_form) %>"/ + product_id);
}
The loaded form has a form_for tag with the :remote => true option and it does add the data-remote="true" attribute to the form.
But the form isn't submitted using Ajax when the user clicks the submit tag button. It works fine if the form is loaded in the standard, non-ajax way, but it the form is loaded via ajax after the document is ready, is does not submit using ajax, it submits as a standard form.
From what I studied so far, this happens because the rails.js file (which contains the stuff that allow data-remote forms to be submitted via ajax) does not apply it's features to html content loaded via ajax.
Is it possible to force rails.js file to apply it's features to content loaded via Ajax?
Same situation here. I found a solution.
Not the dynamic loading, but incorrect triggering of submit event was the cause in my case.
I had a Bootstrap modal with data-target and href attributes set. This causes the content inside a .modal-body to be loaded via AJAX from address specified in href.
The modal was pre-equipped with save button (outside of the loaded form), which called the submit like this.
$modal.find("form.loaded_form").get(0).submit(); // INCORRECT
The former only executes raw submit, but:
$modal.find("form.loaded_form").trigger('submit'); // CORRECT
does the trick.

Yii - how to preload a widget

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.

Implementing a menu's "selected" links in Yii

I have two templates to integrate into yii - my front end website and my CMS.
My front end website has top menu that is generated by CMS (database)
CMS top menu which is static menu by me. ("Manage pages", "Manage users", "Manage products") although this menu is static I still want to assign a selected class to the appropriate top menu item.
Eg: If I'm managing some pages on the site the "Mange pages" link should be highlighted and selected. How would I go about this? Something I need to code myself or is there a existing function in yii that i need to refer to?
Thanks in advance
Yii newbie
What I do is have multiple "menu" functions in my Controller (AdminController extends Controller) class. Each one builds the array the CMenu needs, and I set the active one based on what I passed in to the function. For instance:
protected function getAdminMenu($activeTitle) {
return array(
array('label'=>'Manage pages', 'url'=>array('/user/purchase'),'active'=>($activeTitle=='Manage pages')?true:false),
array('label'=>'Manage users', 'url'=>array('/user/index'),'active'=>($activeTitle=='Manage users')?true:false),
);
}
You could do this where it looks like the Controller or Action or URL request and sets the appropriate menu item active as well. This is just an example.
Then in my view, if I want to render the menu with "Manage pages" active, I set my layout's Menu using the function in my Controller class:
$this->menu=$this->getAdminMenu('Manage pages');
(This assumes that you have public $menu=array(); declared in your Controller, and as well. Look at the Blog example to see how this works:
$this->widget('zii.widgets.CMenu', array(
'items'=>$this->menu,
));
)
I hope this gives you some direction!
Make a css class that changes the background of the object to highlight it.
In your views for the various pages just make the menu item have that particular class.