I would like to know how the events are generated in jquery-ui Sortable Widget?
For example. let’s take the event beforeStop.
My questions are:
-
why does it use
this._trigger("stop", event, this._uiHash());instead ofthis.trigger("stop", event, this._uiHash());? -
what does
_triggerfunction?
_trigger()is a method inherited by all jQuery UI widgets. It calls jQuery’s own trigger() under the hood, but adds the following functionality:The event will be always be triggered on the element the widget augments (the
targetproperty of the event object is updated accordingly).The event that is triggered has the widget prefix prepended to its name (for instance, calling
_trigger("stop")on a sortable widget will actually trigger thesortstopevent).The function returns
falseif one of the registered handlers either returnsfalseor calls preventDefault() on the event.You can find the full implementation of
_trigger()from lines 476 to 503 in the source code here.