Separate routes for ajax

Just a way to specify an alternate route for ajax requests, Mainly in pagination, sort etc.

So when the ajax function is firing it first looks for the url in the data attribute defaulting to the href if one isn’t found.




<a href="nonjavascriptroute" data-jsroute="jsroutehere">Page No.</a>


url = $(this).data('jsroute') || this.href;



Bump.

is it a question alex?

Do you want to find a way? Why don’t you just find out on the route if it is an ajax request (http://www.yiiframework.com/doc/api/1.1/CHttpRequest#getIsAjaxRequest-detail) or not and act according to the request? Will be easier than putting your views with different routes, dont you think?

Cheers

in the onBeginRequest event




if(Yii::app()->getRequest()->isAjaxRequest){

  	Yii::app()->getUrlManager()->rules=array(

     	//new rules

  	);

}



This could just be the specific way I’ve used Yii.

Was to help with people who have javascript disabled.

I have some widgets on a page, If javascript is disabled it’s a full page request.

If ajax can be used it uses a different route with a controller that will work with the widget.