[Html-widget] JS/AJAX with HTML::Widget

Carl Franks fireartist at gmail.com
Tue Aug 22 10:39:50 CEST 2006


On 22/08/06, Tobias Kremer <t at funkreich.de> wrote:
> I searched through the mailing list archives and googled the net high and low
> and still can't believe that I haven't found a single demonstration on how to
> inject JS stuff into a HTML::Widget form. I suppose that's what the Container
> stuff is for, but an example of how to use it would be really helpful. Could
> somebody show me an example of how to include, let's say an onsubmit (form) or
> onclick action? Or is this currently not possible with HTML::Widget?

You can add arbitrary attributes to both the form (widget) and any
element with the 'attributes' hash-ref.

$widget->attributes->{onsubmit} = 'javascript:mymethod(this.form)';

$element->attributes->{onclick} = 'xxx';

I suggest you always use the above method, rather than doing
$widget->attributes( { key => value, key2 => value } ),
as this would delete any attributes already set.

Carl



More information about the Html-widget mailing list