Yii Framework Forum: always return false when opening a CJuiDialog? - Yii Framework Forum

Jump to content

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

always return false when opening a CJuiDialog? Rate Topic: -----

#1 User is offline   nettrinity 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 15-March 11

Posted 26 October 2011 - 11:19 AM

 
    echo CHtml::link('open dialog', '#', array(
            'onclick'=>'$("#mydialog2").dialog("open"); [b]return false;[/b]',
    ));  


this code is from here. Can anybody help me explain we have to return false here?

Thank you!
It's my life!
http://giayhn.com
0

#2 User is offline   elbek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 134
  • Joined: 22-July 10
  • Location:MA, USA

Posted 26 October 2011 - 01:05 PM

When U write return false at this time js stops and u prevent to go js perform somethings.
If u remove it then at the and of the function page jumps.

try with it and without it, u can see difference
Elbek
0

#3 User is offline   nettrinity 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 15-March 11

Posted 26 October 2011 - 01:39 PM

I tried this code
<?php echo CHtml::Button('Join',                    	
                    	array('onClick'=>'{$("#mymodal").dialog("open"); }'
                        	));
?>



with 'return false;' without it, everything is the same. Is it because it's a button tag not a link tag? or I missed something.

Thanks!
It's my life!
http://giayhn.com
0

#4 User is offline   sensorario 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,987
  • Joined: 07-September 10
  • Location:Cesena (Italy)

Posted 26 October 2011 - 09:17 PM

I think there are some mistakes.

<a href="javascript:return false;" onclick="alert('default event is prevent');">click</a>


this work well: return false in href attribute stop the default event. If you remove "return false", when you click you'll see the alert. But also you will open a link. I dont think it has any sense to put return false at onclick attribute.
0

#5 User is offline   nettrinity 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 15-March 11

Posted 26 October 2011 - 10:01 PM

My mistake is I put return false in onClick part. Thanks a lot for clearing that out for me!
It's my life!
http://giayhn.com
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