always return false when opening a CJuiDialog?


 

    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!

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

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!

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.

My mistake is I put return false in onClick part. Thanks a lot for clearing that out for me!