[jQuery] Re: Separate Functions for Events

2008-12-13 Thread DAZ
Just to say a belated thanks to both of you for this help - it is very useful and helped me lots in learning how to use jQuery. I still have lots left to learn, but I'm finding it a great library. cheers, DAZ On Dec 8, 8:35 pm, "Richard D. Worth" wrote: > But also this is a jQuery UI callback,

[jQuery] Re: Separate Functions for Events

2008-12-08 Thread Richard D. Worth
But also this is a jQuery UI callback, which means jQuery UI is already passing two parameters to this function, event, and ui. See http://docs.jquery.com/UI/Droppable/droppable#options "All jQuery UI callbacks receive two arguments: The original browser event and a prepared ui object, view below

[jQuery] Re: Separate Functions for Events

2008-12-08 Thread Michael Geary
> From: DAZ > > Just one more question - what if I need to provide arguments > to the function? Don't these need to go in parens which will > then cause the function to be called immediately? Then you wrap the function call in another function (typically an anonymous function, but could be a r

[jQuery] Re: Separate Functions for Events

2008-12-08 Thread DAZ
Thanks for the replies Richard and Michael, that makes sense and now works! Just one more question - what if I need to provide arguments to the function? Don't these need to go in parens which will then cause the function to be called immediately? cheers, DAZ On Dec 7, 10:55 pm, "Michael Ge

[jQuery] Re: Separate Functions for Events

2008-12-07 Thread Michael Geary
> From: DAZ > > Thanks Michael, the example you gave works great. I'm having > some problems with a droppable though, here is the sample code: > > $("#dropper").droppable({ > accept: "#dragger", > drop: function(ev, ui) {$(this).append("Dropped!");} }); > > The function that is called on t

[jQuery] Re: Separate Functions for Events

2008-12-07 Thread Richard D. Worth
On Sun, Dec 7, 2008 at 3:22 PM, DAZ <[EMAIL PROTECTED]> wrote: > > The function that is called on the drop is likely to get very complex, > so I'd like it in a separate function. > > However, my solution below doesn't work: > > $("#dropper").droppable({ > accept: "#dragger", > drop: dropped() >

[jQuery] Re: Separate Functions for Events

2008-12-07 Thread DAZ
Thanks Michael, the example you gave works great. I'm having some problems with a droppable though, here is the sample code: $("#dropper").droppable({ accept: "#dragger", drop: function(ev, ui) {$(this).append("Dropped!");} }); The function that is called on the drop is likely to get very co

[jQuery] Re: Separate Functions for Events

2008-12-06 Thread Michael Geary
Sure, you can do this, but it's less complicated than that. Don't make your function a method of the jQuery object. Simply make it an ordinary named function with *exactly* the same code as the anonymous function. So your code: $("#test").click(function(){ $(this).css("color","pink") }); b