3

I got a simple UI widget and i'd like it to alert() the "hello world!!!" when initialised.

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

could some one explain how this init or _init function works.? if i was to call the ui just like the dialog ui would $('#selector').dialog() in other words if a click <div onclick="$('#id').myWidget()">Click Me</div> then i should get the alert to pop up.

this code is short because i didnt want to put a lot of coding into it so its easy to read. thanks

1 Answer 1

2

Yes when you call $('#id').myWidget(); it will trigger your _init function to run and fire the alert.

Here is a short post about using the jQuery UI widget factory

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.