Using the jquery bind method I've never seen before

Trying to get comfortable with jQuery, and I came across some sample code that I was having trouble understanding. This refers to the binding method and how they use it. Here

$('textControl').bind(($.browser.opera ? 'keypress', 'keydown') + '.autocomplete', function(event) { code...});

I understand the choice of a keystroke or keydown, but I don't understand why they attach .autocomplete to the name of an even handler?

if someone can shed some light that would be great

thanks

+3
source share
2 answers

These are jQuery features called Namespaced Evenets , which is often used in plugins because it allows an easy and fast way for a plugin to manage its own events.

+5

, .

$('textControl').bind(

textControl

($.browser.opera ? 'keypress', 'keydown')

, - , - keydown.

'.autocomplete'

Autocomplete - , jQuery . , , .

, keypress/keydown, , .

+11

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


All Articles