Hi Tony,

Glad you solved it.

I haven't come across the colour picker you are talking about, but by the sounds of things it is using some of its own custom events, which is what you are really hooking into.

I have been doing a bit of work recently with not only consuming custom events, but firing them as well, and as it turns out they are pretty easy (as you found out).

The other way you could have got it to work, and indeed from a code perspective, allows you to separate the event handling from variable definitions, would be as follows.

new Control.ColorPicker("colorfield4",
      {IMAGE_BASE : "/images/", "swatch" : "colorbox4"}
     );

Control.observe('onEnd', eventHandlerFunction);

Note you may need to remove the 'on' part of the 'onEnd', as Im not sure whether this is a custom event of one such as the 'onClick' event (which is treated as 'click').
Regards

daff
SOFTWARE ENGINEER

andrew 'daff' niles | spider tracks ltd |  117a the square
po box 5203 | palmerston north 4441 | new zealand
P: +64 6 353 3395 | M: +64 21 515 548 E: d...@spidertracks.co.nz <mailto:d...@spidertracks.co.nz> W: www.spidertracks.com <http://www.spidertracks.com>


Tonypm wrote:
SOLVED

I had found an example of using a callback

http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/38d7db4e45341dfb/9c5cfb6ce6cfb860?lnk=gst&q=callbacks#9c5cfb6ce6cfb860

onEnd : function() {
alert('i ended');
}

But didn't know where to put it.

Then when I looked at the new Control.ColorPicker line:

 new Control.ColorPicker("colorfield4",
       {IMAGE_BASE : "/images/", "swatch" : "colorbox4"}
      );

 I realized I could include it in the options hash - I had just never
done that sort of thing before, so as well getting a good color picker
for my project, I have now learned something new.

I put this in the hash

onClose : function() {alert('i changed it to '+ this.field.value);}

and it worked!




On Mar 5, 11:47 am, Tonypm <tonypmar...@hotmail.com> wrote:
Hi,

Need help about using callbacks I don't know if anyone has used
colorpickerjs

http://code.google.com/p/colorpickerjs/

It seems to be a great little colorpicker utility based on
scriptaculous.

I have got it working, but would like to hook into one of the
callbacks to dynamically change the color of a text element on the
page.  The summary page refers to four callbacks, but I cant for the
life of me figure out how to access them.

I have tried accessing the callbacks from the button or the input, but
suspect I need to directly access the control but don't know how.

My js knowledge is a bit limited; I have done some reading on
callbacks but have to admit to being somewhat befuddled.

Thanks for any help
Tonypm


--
You received this message because you are subscribed to the Google Groups "Prototype 
& script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to