Event propagation model prevents drop events from firing #520

austinche opened this Issue Jan 18, 2013 · 6 comments

3 participants


Using this example:

Even though the 'dropstart' event is bound, it never fires. The 'dropinit' event also does not fire. This appears due to slickgrid requiring stopImmediatePropagation() to be called in the handler. The dropinit event is fired as a result of the draginit event. But because slickgrid stops propagation, the dropinit event is not fired after draginit.

If I manually set up drag, e.g. $('#myGrid').bind('drag', function(){}); then I can get all the drop events to fire as expected.


If that were the case, wouldn't the example be broken?


The example is broken for dropstart. Just put an alert in that function to see it's never called. 'drop' and 'dropend' must be called in a different manner from dropinit and dropstart.

@mleibman mleibman closed this in d068650 Jan 18, 2013

Looks like this was caused by an unnecessary stopImmediatePropagation() call in the onDrag handler.


Thanks. That does look to have fixed the dropstart event. However, it doesn't fix the dropinit event. Just as dropstart appears to be triggered by the drag event, dropinit follows from draginit. But removing the stopImmediatePropagation() from the grid.onDragInit() does not work to enable dropinit. This seems to be because of the way handleDragInit is written.


Reopening to investigate.

@mleibman mleibman reopened this Jan 18, 2013
@mleibman mleibman closed this in 8122620 Feb 27, 2013
@dholcombe dholcombe added a commit to dholcombe/SlickGrid that referenced this issue Aug 12, 2013
@dholcombe dholcombe Fix #520 - dropstart event not firing
Copied from mleibman Jan 18, 2013 commit

As I understand 'dropinit' is still not raised because handler of onDragInit shall call to event.stopImmediatePropagation(). The problem is that jQuery.Drag/Drop uses the same instance of event for 'draginit' and 'dropinit' events. And jQuery (at least version 2.0.3) doesn't dispatch event if event.isImmediatePropagationStopped(). I guess the root cause is in jQuery.Drag/Drop. It "hijacks" event object and resets event.isPropagationStopped() but doesn't reset event.isImmediatePropagationStopped() - it looks like a defect.

But it's strange to use event object to prevent cancelling drag. Is it possible to use return value instead of event.stopImmediatePropagation() in onDragInit handler?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment