[Zope3-Users] Javascript and custom widgets

2006-02-09 Thread Rupert Redington
I'm missing something... again...

I've started writing some widgets for my current project, some of which
will make use of some javascript.

I'd like to load a script in the head of the page when such a widget is
being used (so that a window.onload function can parse the dom tree and
apply the relevant javascript to the widget). It seems a shame to add
such a script into the main template of my skin - since that will result
in the script running on every page, regardless of whether its needed.
Also that would deprive my widget of its spangly functions when being
used in another skin - such as rotterdam.

Like-wise I don't really want to write a custom template for the form.
The autoform machinery is so cool...

I hoped to find ZCML directive which would load a resource into a slot
for a particular browser:editForm/addForm. No such luck.

Looking around I found the pagelet directive that tiks uses to overcome
the same problem in places like its fckeditor widget - is this the way
forward? Is the pagelet likely to make it into the core?

What am I missing today?

Thanks in advance for any sage advice.

Rupert
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Javascript and custom widgets

2006-02-09 Thread Gary Poster


On Feb 9, 2006, at 12:38 PM, Rupert Redington wrote:


I'm missing something... again...

I've started writing some widgets for my current project, some of  
which

will make use of some javascript.


This is precisely what we use zc.resourcelibrary for.  It has some  
warts, but we use it, we want to improve it, and it does what we want.


See
http://svn.zope.org/zc.resourcelibrary/trunk/src/zc/resourcelibrary/
and specifically
http://svn.zope.org/zc.resourcelibrary/trunk/src/zc/resourcelibrary/ 
README.txt?view=auto


Gary
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


RE: [Zope3-Users] Javascript and custom widgets

2006-02-09 Thread Roger Ineichen
Hi Ruppert

[...]
 
 Looking around I found the pagelet directive that tiks uses 
 to overcome
 the same problem in places like its fckeditor widget - is this the way
 forward? Is the pagelet likely to make it into the core?

The pagelet get move from tiks to zope and back again ;-)
But there is a replacement in the zope core called zope.viewlet.

Why,
first, we used pagelets which act at the TAL namespace 
and macro level. This seems to be to hard for many developers.
Stephan Richter was refactoring the pagelets and we implemented
the zope.viewlet which are a zope.contentprovider implementation.

If you need a easy concept for register a javascript, you can use
viewlets. btw, they provide a JavaScript viewlet base class which can
be used with the viewlet directive.

But if you like to use the Rotterdam skin, which I think will be 
removed in future releases (perhaps not the next one),
then you have to use the zc.resourcelibrary which Gary Poster
proposed.

The resourcelibrary is a great concept which injects the javascript
tag into the head during post processing.

I didn't use the resoucelibrary, but I guess I will take a look at 
this part in the next future and perhaps use it also in Tiks.

Regards
Roger Ineichen

 What am I missing today?
 
 Thanks in advance for any sage advice.
 
 Rupert
 ___
 Zope3-users mailing list
 Zope3-users@zope.org
 http://mail.zope.org/mailman/listinfo/zope3-users
 

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users