Moving an item programmatically with jQuery sortable while still triggering events

前端 未结 4 1900
Happy的楠姐
Happy的楠姐 2020-12-05 06:20

I am using jQuery Sortable. I have the HTML setup like so:

  • 1
  • 2
4条回答
  •  情书的邮戳
    2020-12-05 07:03

    $("selector").trigger("sortupdate");
    

    you will have to maybe pass in as second argument a function where to put in the event and the ui, event is not as important as ui

    the inside code of the sortable widget for event triggering looks like this

    this._trigger("update", event, this._uiHash(this));
    

    So you may want to do following

    function triggerUpdateFor(selector) {
        var widget = $(selector).sortable("widget");
        if (widget) widget._trigger("update", null, widget._uiHash(widget));
    }
    

提交回复
热议问题