Opened 8 years ago

Closed 8 years ago

#7997 closed enhancement (wontfix)

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.
  1. The API describes what the scope of the function is, rather than the API documentation, improving understandability of the code.
  1. 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.

Change History (1)

comment:1 Changed 8 years ago by Scott González

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.

Note: See TracTickets for help on using tickets.