Skip to main content

Search and Top Navigation

#7997 closed enhancement (wontfix)

Opened January 09, 2012 11:13AM UTC

Closed January 09, 2012 01:12PM UTC

Make scope explicit in callbacks

Reported by: jstutterheim Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.droppable Version: git (not yet released)
Keywords: Cc:
Blocked by: Blocking:
Description

This issue is applicable to a larger set of the jQuery UI API, but I'll describe it in terms of droppable.

The droppable drop callback function currently accepts two arguments: event and ui. Droppable's API documentation also mentions that the scope of this(in particular $(this)) represents the droppable the draggable is dropped on. The main case for this issue: make the this (or $(this)) and explicit argument to the callback, so that we get something along the lines of drop: function (event, ui, dropscope) { ...

One can think of several arguments in favour of this change:

1. A personal one: I'm working on the JavaScript foreign function interface of the Utrecht Haskell Compiler, but haven't found a nice solution for dealing with this yet. Having the context made explicit greatly simplifies my jQuery UI imports into my Haskell code.

2. The API describes what the scope of the function is, rather than the API documentation, improving understandability of the code.

3. Currently the way one works with droppable depends on what the JavaScript engine determines is this. Should the JavaScript language and corresponding implementations change, all apps depending on the contents of this will break. If it is made explicit via a function argument, only jQuery will need to cope with such changes.

Attachments (0)
Change History (1)

Changed January 09, 2012 01:12PM UTC by scottgonzalez comment:1

resolution: → wontfix
status: newclosed

I'll tell you what, if the JavaScript language changes such that this is no longer usable, we'll make this change.