Yii:: Add Onclick to menu link

Posted: June 10, 2011 in Yii Framework

Hi, here is how you can add javascript link to your menu.
Use linkOptions.

$this->menu=array(
    array(‘label’=>’Add New Record’, ‘url’=>array(‘create’)),
        array(‘label’=>’Update Invoice NMB’, ‘url’=>’#’, ‘linkOptions’=>array(‘onclick’=>’jsFunctionHere()’)),
);

<script>
function jsFunctionHere(){
    ..do something here…
}
</script>

Comments
  1. Ankit Modi says:

    Nice……..It was helpul me

  2. Vschettino says:

    Very helpfull!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s