Hi there kazooka. I agree that a deep copy algorithm is really quite
helpful for
component configuration. To cover some of the wrinkles special to the
semantics of configuration, at Fluid we have assembled a custom
options
merging algorithm which is described at
http://wiki.fluidproject.org/display/fluid/Options+Merging+for+Fluid+Components
which takes care of a few cases beyond the use of jQuery.extend
(true, ...)
(which we do use in other situations, where the objects have plain
"data"
semantics).
In your last example, I would probably tend to try to remove
configuration
by use of null rather than undefined, since detecting undefined values
in
hashes can be a little unreliable, but I agree that the basic concept
is
desirable and workable.

A.

On Feb 20, 3:49 pm, 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.

--~--~---------~--~----~------------~-------~--~----~
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