[Organize yourself]
Ajax verification form, paging, Yii ajax Paging
I. ajax has specialized widgets that you can call directly in the view. For example, you can use ajax to verify the form as follows:
<? Php $ form = $ this-> beginWidget ('cactiveform', array ('id' => 'user-form ', 'enablesajaxvalidation '=> true,);?>... Form Content... <? Php $ this-> endWidget ();?>
Paging:
$ Articles = array (); // query condition $ criteria = new CDbCriteria (); $ criteria-> order = ''createdtime 'desc '; $ criteria-> addCondition ("'typeid' = '1' AND 'status' = '1'"); // calculates the total number of records $ count = Article: model () -> count ($ criteria); $ pages = new CPagination ($ count); $ pages-> pageSize = 10; $ pages-> applyLimit ($ criteria ); $ articles = Article: model ()-> findAll ($ criteria );
Yii ajax paging:
Sometimes we need ajax to read data and perform paging. The first thing we encounter is how to load a style sheet. After we get used to automation, we still have to know some basic knowledge.
Add the following on the load page:
$cs = Yii::app()->getClientScript();$url=CHtml::asset(Yii::getPathOfAlias('system.web.widgets.pagers.pager').'.css');$cs->registerCssFile($url);
OK. The style sheet is loaded. How can I paging it. This is actually not a function of yii, but Jquery. We can live a click for the paging link.
Add js and modify the selector as follows:
$('#search_list .yiiPager a').live('click',function(){ $.ajax({ url:$(this).attr('href'), success:function(html){ $('#search_list').html(html); } }); return false;});
Turn: http://www.yiichina.org/forum/thread-982-1-1.html