Jquery initialization function

I have a simple user interface widget and I would like it to warn () "hello world !!!". upon initialization.

$.widget("ui.myWidget", {
   _init: function() {
      //start
      alert('Hello World!!!');
   }
}

Can someone explain how this init or _init function works? if I were to call ui in the same way as in the ui dialog in $('#selector').dialog() other words, if I click <div onclick="$('#id').myWidget()">Click Me</div>, then I should trigger a pop-up warning.

this code is short because I did not want to embed a lot of encodings into it, so it is easy to read. thank

+3
source share
1 answer

, $('# id'). myWidget(); _init .

jQuery UI widget factory

+2

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


All Articles