[Solar-talk] creating a link

Clay Loveless clay at killersoft.com
Sat Sep 2 20:51:23 PDT 2006


On Sep 1, 2006, at 12:15 PM, Ben Barringer wrote:

> What is the best way in solar to create a link like this:
>
> <a href="#" onclick="javascript:alert('hello');">hello</a>

Hi Ben,

The way I'd do this, since I'm on an unobtrusive JavaScript kick, is  
to pull this out of the <a ..> tag itself.

Something like:

<?php
$this->JsPrototype()->event->
       observe('#ahello', 'click', 'function(evt) { alert("hello!");  
Event.stop(evt); }'); ?>



Allows a link like this:

<a id="ahello" href="index.php">hello!</a>



I'm working on several Prototype and script.aculo.us helpers right  
now, and this seems like it would be nicely wrapped in something like  
'observeClick()' helper.

Regards,
Clay


--
Killersoft.com





More information about the solar-talk mailing list