0

I have the following piece of code:

  <ul ui-sortable ng-model="list">
    <!-- onDragStartHandler() is a global function, not part of $scope -->
    <li draggable ondragstart="onDragStartHandler();" ng-repeat="item in list">Item: {{item}}</li>
  </ul>

When ui-sortable (github) directive is used, the code attached to ondragstart is not executed at all.

You can see this here.

Any ideas how this event handler can be invoked as well?

1 Answer 1

1

My guess is, the ui-sortable manipulates the dom and removes the event handlers.

If you look at their options - you can probably wire into the callbacks like so:

<ul ui-sortable="sortableOptions" ng-model="list">
  <!-- onDragStartHandler() is a global function, not part of $scope -->
  <li draggable ng-repeat="item in list">Item: {{item}}</li>
</ul>

and your controller:

$scope.sortableOptions = {
  start: onDragStartHandler(e, ui)
};

Because onDragStartHandler is a global function - remember that you may need to $apply() the scope to see updates to bindings.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.