Yii Framework Forum: CHtml::ajaxLink & disabled javascript - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CHtml::ajaxLink & disabled javascript spiders & solution Rate Topic: -----

#1 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 03 March 2010 - 08:26 AM

CHtml::ajaxLink works perfectly, but not works if javascript is disabled (and some spiders not understand this construction)... for preventing "bug" I propose render ajaxLink as:

	public static function ajaxLink($text,$url,$ajaxOptions=array(),$htmlOptions=array())
	{
		$htmlOptions['href']=$url;
                // can be opened in new window
                if(!isset($ajaxOptions['url'])){
                        $ajaxOptions['url']='js:this.href';
			$htmlOptions['href']=$url;
		}
                // current logic
		else
			$htmlOptions['href']='#';
		$htmlOptions['ajax']=$ajaxOptions;
		self::clientChange('click',$htmlOptions);
		return self::tag('a',$htmlOptions,$text);
	}



response in case of ajaxRequest:
 if(Yii::app()->request->isAjaxRequest)
   $this->renderPartial('template',$data,false,true);
 else
   $this->render('template',$data);

-Posted Image-
Thanks, you make me stronger!
0

#2 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 13 March 2010 - 05:09 AM

Qiang, pay attention... now ajaxlink can't be opened in new window <_< + it's not friendly (as for me: I rarely use links with "#" or "javascript:void(0);")
-Posted Image-
Thanks, you make me stronger!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users