Yii Framework Forum: How to disalble chtml link - Yii Framework Forum

Jump to content

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

How to disalble chtml link Rate Topic: -----

#1 User is offline   angela88 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 14-October 11
  • Location:Jakarta

Posted 21 November 2011 - 09:12 PM

i want to disable chtml link with one condition..
how to disable link???
i try this with but not work
CHtml::link('Add Icon',array('/image/createIcon','idContent'=>$model->id_content, array('disable'=>true))); 


thanks in advance..
0

#2 User is offline   Pravin Gajera 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 137
  • Joined: 25-October 11
  • Location:India

Posted 22 November 2011 - 01:39 AM

hi

you can't disable direct this way but use css class like below

echo CHtml::link('Add Icon',array('/image/createIcon','idContent'=>$model->id_content), array('class'=>'css_class_name'));
0

#3 User is offline   angela88 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 14-October 11
  • Location:Jakarta

Posted 23 November 2011 - 10:33 PM

View PostPravin Gajera, on 22 November 2011 - 01:39 AM, said:

hi

you can't disable direct this way but use css class like below

echo CHtml::link('Add Icon',array('/image/createIcon','idContent'=>$model->id_content), array('class'=>'css_class_name'));


can u show me the code of css?
sorry if i ask stupid question but i'm new in programing web n yii..
0

#4 User is offline   Joblo 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 378
  • Joined: 12-September 10
  • Location:Austria

Posted 24 November 2011 - 02:06 AM

You have to disable the 'onclick' too:

CHtml::link('Add Icon',array('/image/createIcon','idContent'=>$model->id_content, array('onclick'=>'return false;','style'=>'color:gray;'))); 

0

#5 User is offline   angela88 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 14-October 11
  • Location:Jakarta

Posted 27 November 2011 - 09:08 PM

View PostJoblo, on 24 November 2011 - 02:06 AM, said:

You have to disable the 'onclick' too:

CHtml::link('Add Icon',array('/image/createIcon','idContent'=>$model->id_content, array('onclick'=>'return false;','style'=>'color:gray;'))); 



didn't work to me...
0

#6 User is offline   marcovtwout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 16-September 10
  • Location:Delft, NL

Posted 28 November 2011 - 08:12 AM

View PostAngela Ari, on 27 November 2011 - 09:08 PM, said:

didn't work to me...


It has a typo. Correction:
CHtml::link('Add Icon',array('/image/createIcon','idContent'=>$model->id_content), array('onclick'=>'return false;','style'=>'color:gray;')); 

Yii-Environment Extension - Predefine configurations for use in different environments, like development, testing, staging and production.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
0

#7 User is offline   Gerhard Liebenberg 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 200
  • Joined: 07-January 12
  • Location:Stillbay - Western Cape - South Africa

Posted 08 October 2012 - 01:47 AM

If I do this:
array('onclick'=>'return false;','style'=>'color:gray;')); 

the button disables without first submitting the form.

How do you disable the button after first submitting the form?
0

#8 User is offline   Gerhard Liebenberg 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 200
  • Joined: 07-January 12
  • Location:Stillbay - Western Cape - South Africa

Posted 08 October 2012 - 05:15 AM

I got it working with jquery. Is there a better way?


<?php
	echo CHtml::link($caption,'#', array(
		'id'=>'btnSubmitMisc',
		'submit'=>array($actionUrl),
		'class'=>'myCHtmlButton',
	));
?>

<?php
	Yii::app()->clientScript->registerScript('submitTest', "
	$('#btnSubmitMisc').click(function(){
		if($('#btnSubmitMisc').hasClass('myCHtmlButton'))
			{
				$('#btnSubmitMisc').removeClass('myCHtmlButton');
				$('#btnSubmitMisc').addClass('myCHtmlButtonClicked');
			}
			else
			{
				return false;  // Don't submit if class is myCHtmlButtonClicked
			}
		});
	");
?>

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