Jquery UI sortable - perform action BEFORE start event fires

后端 未结 2 2174
南旧
南旧 2021-02-07 15:52

I have searched STACKOVERFLOW and other forums for the solution to my problem - if I have missed a working solution please point me towards it.

My Problem: Whenever drag

2条回答
  •  自闭症患者
    2021-02-07 16:30

    You can do this, but it's not future proof for upcoming versions of jQuery UI:

    var oldMouseStart = $.ui.sortable.prototype._mouseStart;
    $.ui.sortable.prototype._mouseStart = function(event, overrideHandle, noActivation) {
       this._trigger("CustomBeforeStart", event, this._uiHash());
       oldMouseStart.apply(this, [event, overrideHandle, noActivation]);
    };
    

    You can then use the new event when setting up the sortable:

    $(".whatever").sortable({
      "CustomBeforeStart":function(e, ui) {
      }
      ...
    });
    

提交回复
热议问题