Feel free to start a thread about this in the jquery-ui-dev group and
I'll check out all of our existing plugins to see where this would
have an effect (should be extremely limited).

As a side note, the UI guidelines suggest that a plugin that utilizes
another plugin should not expose the other plugin's raw options.  For
an example of this, take a look at the dialog plugin which utilizes
the draggable and resizable plugins.  None of the draggable or
resizable plugin options are directly exposed; only a limited subset
of the options are exposed and they're exposed in a way that makes
sense for dealing specifically with dialogs.  The idea behind this is
to keep our API clean and have our documentation for any given plugin
be fully self-contained.


On Feb 20, 10:49 am, kazooka <[email protected]> wrote:
> Why aren't widgets meant to have complex options? I have a custom
> widget that utilizes other widgets and plugins inside of it's
> prototype. It is very convenient to be able to pass options for the
> member widgets and plugins 'as is'. For example:
>
> // Supppose these are the defaults for myLittleWidget...
> $.ui.myLittleWidget.defaults{
>         'color':                'green',
>         'width':                '100px',
>         'flash':                true,
>         'speed':                'fast'
>         'onSuccess':    function(){
>                 alert('Thank you for your participaiton.');
>         }
>
> }
>
> // Supppose these are the defaults for myLittleWidget...
> $.ui.mySuperWidget.defaults = {
>         'size': 50,
>         'color': 'orange',
>         'myLittleWidgetOptions': {}
>
> }
>
> /*** WITHOUT DEEP COPY you have to know ALL of the default options
> just to change one. ***/
> // change value of 'speed' option
> $('#super').mySuperWidget({
>         'myLittleWidgetOptions': {
>                 'color':                'green',
>                 'width':                '100px',
>                 'flash':                true,
>                 'speed':                'slow'
>                 'onSuccess':    function(){
>                         alert('Thank you for your participaiton.');
>                 }
>         }
>
> });
>
> // remove 'color' option
> $('#super').mySuperWidget({
>         'myLittleWidgetOptions': {
>                 'width':                '100px',
>                 'flash':                true,
>                 'speed':                'slow'
>                 'onSuccess':    function(){
>                         alert('Thank you for your participaiton.');
>                 }
>         }
>
> });
>
> /*** WITH DEEP COPY you only have to know about the options you want
> to change. ***/
> // change value of 'speed' option
> $('#super').mySuperWidget({
>         'myLittleWidgetOptions': {
>                 'speed':                'slow'
>         }
>
> });
>
> // remove 'color' option
> $('#super').mySuperWidget({
>         'myLittleWidgetOptions': {
>                 'color':                undefined
>         }
>
> });
>
> I just think a deep copy would be more friendly toward building new
> widgets upon existing ones.
>
> On Feb 19, 8:00 pm, Scott González <[email protected]> wrote:
>
> > UI plugins aren't meant to have complex options.  Currently the only
> > place where we have objects as options, it doesn't make sense to do a
> > deep extend.  Also, doing a deep extend would be problematic if there
> > were values that the user wanted to remove from the defaults.
>
> > On Feb 18, 10:55 am, kazooka <[email protected]> wrote:
>
> > > I'm creating custom widgets with 1.6rc6 and I noticed that when
> > > creating a custom widget, the default options are NOT deep copied to
> > > the options passed in during instantiation. For example:
>
> > > // Create the widget
> > > $.widget('myWidget', {
> > >     init: function (){
> > >             /*
> > >               At this point, given the defaults and the instantiation
> > > below,
> > >               I would expect the this.options to contain...
> > >                  {
> > >                       title: 'My Widget',
> > >                       classes: {
> > >                             'header':  '.my-widget-header',
> > >                             'content': '.my-widget-content',
> > >                             'footer': '.custom-widget-footer'
> > >                       }
> > >                   }
>
> > >                Instead, this.options contains (because of no 'deep
> > > copy')...
> > >                  {
> > >                       title: 'My Widget',
> > >                       classes: {
> > >                             'footer': '.custom-widget-footer'
> > >                       }
> > >                   }
> > >             */
> > >         }
> > >     }
> > > );
>
> > > // Set the widget defaults
> > > $.ui.myWidget.defaults = {
> > >     title: 'My Widget',
> > >     classes: {
> > >         'header':  '.my-widget-header',
> > >         'content': '.my-widget-content',
> > >         'footer': '.my-widget-footer'
> > >     }
>
> > > }
>
> > > // Widgefy an element on the page with id='my-widget'
> > > var testWidget = $('#my-widget').myWidget({
> > >     classes: {
> > >          'footer': '.custom-widget-footer'
> > >     }
>
> > > }
>
> > > ---------
> > > To me a deep copy makes more sense.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to