Maybe use MochiKit.Base.merge or MochiKit.Base.update:
function CHECKBOX() {
return INPUT.apply(this, update(arguments, {'type': "checkbox"}));
}
- Kevin
On Dec 17, 2007 1:30 PM, machineghost <[EMAIL PROTECTED]> wrote:
>
> I recently found myself doing this a lot:
> var a = INPUT({type:"textbox"});
> var b = INPUT({type:"checkbox"});
> var c = INPUT({type:"hidden"});
> etc.
>
> So I wanted to make short-hand functions like CHECKBOX and HIDDEN
> which would work exactly like INPUT, only with a pre-specified type.
> At first I thought I could do this:
> CHECKBOX = createDOMFunc("input", {type:"checkbox"});
>
> but that eliminated all other attributes (since the {type:"checkbox"}
> replaced my attributes argument). I played around a bit, and
> eventually found that I could make it work with:
> function CHECKBOX(){
> arguments[0]["type"] = "checkbox";
> return INPUT.apply(this, arguments);
> }
>
> But that doesn't seem very MochiKit-ish to me, so I was wondering if
> there was a cleaner way to do the above using bind or partial or
> something. Also, I was curious as to how people feel about these
> short-hand functions, and whether or not they'd be useful enough to
> include in MochiKit.DOM.
>
> Any thoughts/feedback would be appreciated.
> Jeremy
>
>
>
> So my question is, is th
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" 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/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---