views:

459

answers:

2

Trying to use an onmouseover event

echo $html->link("Dashboard", 
     "/dashboard/index", 
     array("onmouseover" => "Tip('Test');") );

becomes

<a href="/dashboard/index" onmouseover="Tip(&#039;Test&#039;);">Dashboard</a>

How do I prevent the link function from removing the single quotes?

+1  A: 

This should work:

echo $html->link("Dashboard", 
     "/dashboard/index", 
     array("onmouseover" => "Tip('Test');"),
     array('escape' => false));
David Weitz
added onclick="return confirm('Array');" after the onmouseover. It went into the confirm return true/false parameter of link.
Jack B Nimble
+1  A: 

Using Cake 1.2, this should definitely work:

echo $html->link('Dashboard', '/dashboard/index',
array("onmouseover" => "Tip('Test');"), null, false);

The last parameter is the escape option. It defaults to true.

MSR