JQDroppable convience method

6 messages Options
Embed this post
Permalink
Johan Brichau

JQDroppable convience method

Reply Threaded More More options
Print post
Permalink
Hi,

While working with JQuery's draggable/droppable plugins in Seaside, I  
was missing the convenient "passenger callbacks" that Scriptaculous  
had. Therefore I added the following convenience method to  
JQDroppable. You can pass it a block that will be invoked with the  
passenger of the draggable that was dropped onto it.

Would it make sense to add it to the plugin's distributed version?
And if I am making things overly complicated, that would be glad to  
know as well ;-)

cheers,

onDropCallback: aBlock
        self onDrop:
                (((JQueryClass context: self renderContext) ajax
                                callback: [:value | aBlock value: (self renderContext callbacks  
passengerAt: value)]
                                value: (JSStream on: '$(ui.draggable).get(0).id'))
                        asFunction: #(event ui))

----------------------------
Johan Brichau
[hidden email]




_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Lukas Renggli

Re: JQDroppable convience method

Reply Threaded More More options
Print post
Permalink
I typically do something along the lines of:

    ... onDrop: (html jQuery ajax
       tigger: [ :object | ... ] passengers: html jQuery this)

The method #trigger:passengers: takes a block that is evaluated with a
collection of passengers from the query passed in as the second
argument.

Lukas

2009/10/27 Johan Brichau <[hidden email]>:

> Hi,
>
> While working with JQuery's draggable/droppable plugins in Seaside, I was
> missing the convenient "passenger callbacks" that Scriptaculous had.
> Therefore I added the following convenience method to JQDroppable. You can
> pass it a block that will be invoked with the passenger of the draggable
> that was dropped onto it.
>
> Would it make sense to add it to the plugin's distributed version?
> And if I am making things overly complicated, that would be glad to know as
> well ;-)
>
> cheers,
>
> onDropCallback: aBlock
>        self onDrop:
>                (((JQueryClass context: self renderContext) ajax
>                                callback: [:value | aBlock value: (self
> renderContext callbacks passengerAt: value)]
>                                value: (JSStream on:
> '$(ui.draggable).get(0).id'))
>                        asFunction: #(event ui))
>
> ----------------------------
> Johan Brichau
> [hidden email]
>
>
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Johan Brichau

Re: JQDroppable convience method

Reply Threaded More More options
Print post
Permalink
Hi Lukas,

That's right but $(this) is bound to the droppable, while it's often  
convenient to get the object that was dragged onto it (the draggable).
Using the trigger:passengers: approach, it seems impossible to me to  
get to the draggable.

Or am I missing something?

On 27 Oct 2009, at 23:31, Lukas Renggli wrote:

> I typically do something along the lines of:
>
>    ... onDrop: (html jQuery ajax
>       tigger: [ :object | ... ] passengers: html jQuery this)
>
> The method #trigger:passengers: takes a block that is evaluated with a
> collection of passengers from the query passed in as the second
> argument.
>
> Lukas
>
> 2009/10/27 Johan Brichau <[hidden email]>:
>> Hi,
>>
>> While working with JQuery's draggable/droppable plugins in Seaside,  
>> I was
>> missing the convenient "passenger callbacks" that Scriptaculous had.
>> Therefore I added the following convenience method to JQDroppable.  
>> You can
>> pass it a block that will be invoked with the passenger of the  
>> draggable
>> that was dropped onto it.
>>
>> Would it make sense to add it to the plugin's distributed version?
>> And if I am making things overly complicated, that would be glad to  
>> know as
>> well ;-)
>>
>> cheers,
>>
>> onDropCallback: aBlock
>>        self onDrop:
>>                (((JQueryClass context: self renderContext) ajax
>>                                callback: [:value | aBlock value:  
>> (self
>> renderContext callbacks passengerAt: value)]
>>                                value: (JSStream on:
>> '$(ui.draggable).get(0).id'))
>>                        asFunction: #(event ui))
>>
>> ----------------------------
>> Johan Brichau
>> [hidden email]
>>
>>
>>
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>
>
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

----------------------------
Johan Brichau
[hidden email]




_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Lukas Renggli

Re: JQDroppable convience method

Reply Threaded More More options
Print post
Permalink
> That's right but $(this) is bound to the droppable, while it's often
> convenient to get the object that was dragged onto it (the draggable).
> Using the trigger:passengers: approach, it seems impossible to me to get to
> the draggable.
>
> Or am I missing something?

No, this is jQuery that is missing something ;-)

Currently there is almost no support to get the parameters from events
back into the image. I will add some helper methods to JQAjax to make
this simpler. I am not particularly fond of adding something like
#onDropCallback: because this hardcodes an AJAX request and does not
give the user the possibility to define additional AJAX actions,
render something, change something, etc.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Lukas Renggli

Re: JQDroppable convience method

Reply Threaded More More options
Print post
Permalink
I've quickly added some convenience methods to JQAjax that serialize
the information of the jQueryUI events:

     #callbackAccordion:
     #callbackDraggable:
     #callbackDroppable:
     #callbackResizable:
     #callbackSlider:
     #callbackSortable:
     #callbackTabs:

All these callbacks expect a block with one argument that gets
evaluated with a dictionary of the event elements as documented in the
jQueryUI documentation.

Johan, your code would now look like this:

    ... onDrop: (html ajax
        callbackDroppable: [ :event |
            (event at: #draggable) doSomething ])

Note that I also renamed #trigger:passengers: to
#callback:passengers:, that fits better the jQuery protocol.

Let me know if this is useful or if there is something else missing.
This is mostly untested functionality so expect to encounter bugs.

Cheers,
Lukas






2009/10/28 Lukas Renggli <[hidden email]>:

>> That's right but $(this) is bound to the droppable, while it's often
>> convenient to get the object that was dragged onto it (the draggable).
>> Using the trigger:passengers: approach, it seems impossible to me to get to
>> the draggable.
>>
>> Or am I missing something?
>
> No, this is jQuery that is missing something ;-)
>
> Currently there is almost no support to get the parameters from events
> back into the image. I will add some helper methods to JQAjax to make
> this simpler. I am not particularly fond of adding something like
> #onDropCallback: because this hardcodes an AJAX request and does not
> give the user the possibility to define additional AJAX actions,
> render something, change something, etc.
>
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
>



--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Johan Brichau

Re: JQDroppable convience method

Reply Threaded More More options
Print post
Permalink

On 28 Oct 2009, at 13:03, Lukas Renggli wrote:

> Johan, your code would now look like this:
>
>    ... onDrop: (html ajax
>        callbackDroppable: [ :event |
>            (event at: #draggable) doSomething ])

That is indeed very nice. Thanks Lukas!

> Note that I also renamed #trigger:passengers: to
> #callback:passengers:, that fits better the jQuery protocol.

yes, indeed.

> Let me know if this is useful or if there is something else missing.
> This is mostly untested functionality so expect to encounter bugs.

will do ;-)

----------------------------
Johan Brichau
[hidden email]




_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside