Kamal Gill | 9 Aug 22:56

Adding a javascript event handler to a widget

How do I add a javascript event handler to a widget?  For example, how 
would I add the HTML attribute onFocus="select()" to a StringWidget?  
My suspicion is to use the attributes property of the widget, but I am 
unable to find any documentation or usage examples regarding the 
attributes property of Archetype widgets.  Any help is much 
appreciated.

  - Kamal

-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
Dorneles Treméa | 9 Aug 23:28
Gravatar

Re: Adding a javascript event handler to a widget

Hi Kamal,

> How do I add a javascript event handler to a widget?  For example, how 
> would I add the HTML attribute onFocus="select()" to a StringWidget?  
> My suspicion is to use the attributes property of the widget, but I am 
> unable to find any documentation or usage examples regarding the 
> attributes property of Archetype widgets.  Any help is much 
> appreciated.

currently there are only some rough ideas sleeping in some
minds around the world about the best approach for JS events
(onclick, onfocus, onchange, ...) :-)

A new property on widgets sounds reasonable.

I suggest you write your thoughts, so we can got consensus
about the idea and effectively implement it on AT.

Regards,

--

-- 

Dorneles Treméa
Caxias do Sul - RS - Brasil
+55 54 9114 9312 - UIN: 2413568
X3ng Web Technology <http://www.x3ng.com.br>

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/IT d- s:->: a25 C+++ UBL++++$ P--- L++ E-- W+++
(Continue reading)

Kamal Gill | 10 Aug 00:14

Re: Re: Adding a javascript event handler to a widget

Hi Dorneles,

Thanks for your reply.  Here are my thoughts on how HTML/XML attributes 
should be handled in AT.

If the attributes property is currently a placeholder for some desired 
functionality, perhaps it could be used to allow *any* HTML/XML 
attribute to be generated by the widget.  My proposal is to allow the 
attributes property of the widget to be passed as a dictionary to the 
generator, as in the following example...

schema = BaseSchema + Schema((
     StringField('Field_ID',
                     widget=StringWidget(label='some_label ',

attributes={'onFocus': 'select()', 'onChange': 'someJSfunction()', 
'anyXMLattribute': 'anyXMLattributeValue'},

description='some_description'),
               ),

The flexibility of this approach may even allow TAL statements to be 
added to widgets.  Does this sound reasonable?

  - Kamal

On Aug 9, 2004, at 2:28 PM, Dorneles Treméa wrote:

> Hi Kamal,
>
(Continue reading)

Christian Heimes | 10 Aug 19:22

Re: Adding a javascript event handler to a widget

Kamal Gill wrote:
> Hi Dorneles,
> 
> Thanks for your reply.  Here are my thoughts on how HTML/XML attributes 
> should be handled in AT.
> 
> If the attributes property is currently a placeholder for some desired 
> functionality, perhaps it could be used to allow *any* HTML/XML 
> attribute to be generated by the widget.  My proposal is to allow the 
> attributes property of the widget to be passed as a dictionary to the 
> generator, as in the following example...
> 
> schema = BaseSchema + Schema((
>     StringField('Field_ID',
>                     widget=StringWidget(label='some_label ',
>                                                    
> attributes={'onFocus': 'select()', 'onChange': 'someJSfunction()', 
> 'anyXMLattribute': 'anyXMLattributeValue'},
>                                                    
> description='some_description'),
>               ),
> 
> The flexibility of this approach may even allow TAL statements to be 
> added to widgets.  Does this sound reasonable?

+1
Please provide a patch against the latest 1.3 branch.

Christian

(Continue reading)

Kamal Gill | 11 Aug 18:19

Re: Re: Adding a javascript event handler to a widget

Hi Christian,

I would love to add this functionality to AT 1.3, but my knowledge of 
AT and CVS is a bit rudimentary at this point.  Since I consider myself 
to be an AT user rather than a developer at this time, I will humbly 
pass the responsibility to someone with more expertise.  My apologies 
for sounding like I know more than I do.

Would anyone like to volunteer to add the patch to the 1.3 branch?

  - Kamal

On Aug 10, 2004, at 10:22 AM, Christian Heimes wrote:

> Kamal Gill wrote:
>> Hi Dorneles,
>> Thanks for your reply.  Here are my thoughts on how HTML/XML 
>> attributes should be handled in AT.
>> If the attributes property is currently a placeholder for some 
>> desired functionality, perhaps it could be used to allow *any* 
>> HTML/XML attribute to be generated by the widget.  My proposal is to 
>> allow the attributes property of the widget to be passed as a 
>> dictionary to the generator, as in the following example...
>> schema = BaseSchema + Schema((
>>     StringField('Field_ID',
>>                     widget=StringWidget(label='some_label ',
>>                                                    
>> attributes={'onFocus': 'select()', 'onChange': 'someJSfunction()', 
>> 'anyXMLattribute': 'anyXMLattributeValue'},
>>                                                    
(Continue reading)

Dorneles Treméa | 12 Aug 22:47
Gravatar

Re: Adding a javascript event handler to a widget

Hi Kamal,

> Would anyone like to volunteer to add the patch to the 1.3 branch?

add a feature request to SourceForge Archetypes site and
assigns it to me. Hopefully it'll be implemented in the
next days/weeks.

Regards,

-- 

Dorneles Treméa
Caxias do Sul - RS - Brasil
+55 54 9114 9312 - UIN: 2413568
X3ng Web Technology <http://www.x3ng.com.br>

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/IT d- s:->: a25 C+++ UBL++++$ P--- L++ E-- W+++
N++ o? K? w+ O M+ V-- PS+ PE- Y-- PGP++ t+ 5 X++ R+
tv+ b(++) DI+ D++ G+>+++ e++>++++ h---- r+++ y+++**
------END GEEK CODE BLOCK------

-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
(Continue reading)

Kamal Gill | 16 Aug 20:09

Re: Re: Adding a javascript event handler to a widget

Hi Dorneles,

Wonderful--thanks for your efforts.  I submitted the feature request to 
sf.net with the summary "Request ability to generate XHTML attributes 
in widgets".

  - Kamal

On Aug 12, 2004, at 1:47 PM, Dorneles Treméa wrote:

> Hi Kamal,
>
>> Would anyone like to volunteer to add the patch to the 1.3 branch?
>
> add a feature request to SourceForge Archetypes site and
> assigns it to me. Hopefully it'll be implemented in the
> next days/weeks.
>
> Regards,
>
> -- 
>
> Dorneles Treméa
> Caxias do Sul - RS - Brasil
> +55 54 9114 9312 - UIN: 2413568
> X3ng Web Technology <http://www.x3ng.com.br>
>
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GCS/IT d- s:->: a25 C+++ UBL++++$ P--- L++ E-- W+++
(Continue reading)

Re: Adding a javascript event handler to a widget

Kamal Gill wrote:

> Hi Dorneles,
> 
> Wonderful--thanks for your efforts.  I submitted the feature request to 
> sf.net with the summary "Request ability to generate XHTML attributes in 
> widgets".
> 
>  - Kamal
> 

I had a look at it. There is no quick and easy way to add this feature 
in a general way the way widgets are handled today. - So it will not be 
implemented before 1.3 at least.

it would be possible to add a mapping so that you can add pre-defined 
attributes to a widget. So if one went through all the widgets checking 
what attributes there would be any use for, they could be added to the 
widgets on a per-widget-basis..

- But most usecases for this could just as easily be handled with 
javascript / css like today, now that all widgets have proper 
identifiers and classes.

:)

--

-- 
__________________________________________________________________

  Geir Bækholt    ·    Interaction Engineer   ·    Plone Solutions
(Continue reading)

Paul Boos | 11 Aug 15:44
Favicon

Re: Adding a javascript event handler to a widget

Geir Bækholt · Plone Solutions <lists@...> writes:
> 
>>...snip...
> 
> I had a look at it. There is no quick and easy way to add this feature 
> in a general way the way widgets are handled today. - So it will not be 
> implemented before 1.3 at least.
> 
> it would be possible to add a mapping so that you can add pre-defined 
> attributes to a widget. So if one went through all the widgets checking 
> what attributes there would be any use for, they could be added to the 
> widgets on a per-widget-basis..
> 
> - But most usecases for this could just as easily be handled with 
> javascript / css like today, now that all widgets have proper 
> identifiers and classes.
> 
> :)
> 

We have been following this thread and plan (because of another need) to produce
a way of handling this directly in Archetypes as properties to be contributed
back to the Archetypes project.  Geir - can we interface with you on this?  We
think it could become a standard for a future Archetypes release.  

Their would be registered events in both the edit and view for both attributes
and the classes/objects themselves.  These events could then be assigned a
property of the JavaScript function taht is desired (which could be contained in
the helper.js)

(Continue reading)


Gmane