Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

[Proposal] Allow Cancel Later Than First Update() #254

Open
@jchamberlain

Description

@jchamberlain

When using ui-sortable with connected lists, a drag can only be cancelled in the first call to update(). However, the first time update() is called one often does not have enough information to make a decision on whether to cancel. Let me give an example.

Say I have two connected lists, where some entries may be in both lists, but where neither list can contain the same entry twice:

List 1 List 2
Chicago Los Angeles
Seattle Dallas
Seattle
Miami

If I drag "Seattle" from one list to the other, I want ui-sortable to cancel in order to prevent a duplicate. But in the first call to update(), ui.item.sortable.moved is not yet set (remove() hasn't run), so I don't know that I'm dragging Seattle. I see three possible solutions:

  1. Let the developer figure out which model is being moved and what model it's being moved into based on the DOM elements/index. This is less than ideal, in that I don't like to have jQuery in my controllers. OR...
  2. Change stop() in ui-sortable so that it detects a cancelled move and undoes the splice that remove() did, i.e., restore the models to their original condition. This would allow a cancel in the second update() or even in receive(). OR...
  3. Set additional properties on ui.item.sortable during start(), so that the developer has more information in the first run of update(), without having to query the DOM. Additional info could include the model of the sending list and model of the moved item. In the first internal update() callback, the model of the target list could also be set, if applicable. That would provide everything needed to detect a potential duplicate in the target list.

Obviously I would favor 2 or 3, or maybe even 2 and 3 both.

ORIGINAL TITLE: [Proposal] Allow Cancel Later Than First Update() OR Provide More Options

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions