How event generation is generated in jquery-ui

I would like to know how events are generated in jQuery-ui Sortable Widget?

For instance. let's say the beforeStop event. My questions:

  • why does he use this._trigger("stop", event, this._uiHash()); instead of this.trigger("stop", event, this._uiHash()); ?

  • What does the _trigger function _trigger ?

+4
source share
1 answer

_trigger() is a method inherited by all jQuery UI widgets. It calls jQuery's own trigger () under the hood, but adds the following functions:

  • The event will always be fired in the element that adds the widget (the target property of the event object changes accordingly).

  • The event that fires has a widget prefix added to its name (for example, calling _trigger("stop") on the sortable widget actually triggers the sortstop event).

  • The function returns false if one of the registered handlers returns false or calls preventDefault () in the event.

You can find the full implementation of _trigger() from lines 476 to 503 in the source code here .

+3
source

Source: https://habr.com/ru/post/1445557/


All Articles