concept initialization in category jQuery

appears as: initialization, initialization
jQuery UI in Action

This is an excerpt from Manning's book jQuery UI in Action.

$( "#does-not-exist" ).dialog( "close" );
> Error: cannot call methods on dialog prior to initialization;
attempted to call method 'close'

All widget actions after initialization happen as method calls. Methods query the current state of the widget as well as alter it. Options let you set a dialog’s initial height, width, and title; methods let you change those values, open a dialog, close it, and destroy it.

This type of initialization is known as declarative initialization. As opposed to imperative initialization—where you need to list out option values explicitly in code—declarative initialization lets you associate a widget’s options directly on the HTML elements. I personally find declarative initialization to be elegant as it removes boilerplate JavaScript code.

Extending jQuery

This is an excerpt from Manning's book Extending jQuery.

Not every plugin can be reduced to requiring no options on initialization. For example, my Countdown plugin isn’t particularly useful without a target time to count down to, but there’s no one default value that would apply in most cases.

  • Retrieving and setting option values after initialization
  • Listing 8.4. Attachment and initialization