Siri: jQuery: Widget-Konzept

Beitrag lesen

Hallo,

ich versuch mich gerade in jQuery-UI einzuarbeiten.
Im Tutorial gibt es den Abschnitt Widget-Factory mit dem Beispiel-Code:

$.widget( "custom.superDialog", $.ui.dialog, {  
red: function() {  
this.element.css( "color", "red" );  
}  
});  
// Create a new <div>, convert it into a superDialog, and call the red() method.  
$( "<div>I am red</div>" )  
.superDialog()  
.superDialog( "red" );

In der API den Abschnitt Dialog mit dem Beispiel:

<div id="dialog" title="Basic dialog">  
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>  
</div>

$( "#dialog" ).dialog();

Mir erschließt sich jetzt nicht auf Anhieb, wann das Widget-Konzept besser ist als die "schlichte" Vorgehensweise.

Kann mich jemand aufhellen?

Viele Grüße
Siri