I've found that writing my code with a modular OOP plugin mentality,
it's a lot easier to reuse my own code and trade snippets with others,
since it's already abstracted into a plugin.

I don't know if you've seen Mike Alsup's recent Learning jQuery post
about Plugin Dev, but it's a good read about good plugin practices:
http://www.learningjquery.com/2007/10/a-plugin-development-pattern

Keep it up, it'll be good to see how the code turns out.

Charles


On Oct 31, 2:53 pm, Adrian Lynch <[EMAIL PROTECTED]> wrote:
> Thanks all. I did have a think about which way around I wanted it to
> work. Thinking about what will be returned is also handy.
>
> I can see me wrting more plugins now.
>
> Thanks again.
>
> Adrian
>
> On Oct 30, 2:51 am, Dave Methvin <[EMAIL PROTECTED]> wrote:
>
> > > $(ELEMENTS_TO_CHANGE).syncValue(ELEMENT_I_WISH_TO_COPY).show();
> > > That way your focus is on the changing element.
>
> > I tend to agree; if that's what you want then it's pretty short
> > already.
>
> > $(syncElements).val(formatter(elementToCopy.val())).show();
>
> > The other way around isn't a lot longer but it's uglier.
>
> > $(elementToCopy).each(function(){$(syncElements).val(formatter($
> > (this).val())))}).show();
>
> > So the plugin could just encapsulate the ugliness:
>
> >  jQuery.fn.syncValue = function(syncElements, formatter) {
> >    return this.each(function(){
> >       $(syncElements).val(
> >          (formatter || function(x){return x}}($(this).val()))
> >       );
> >    });
>
> > };
>
> > $(elementToCopy).syncValue(syncElements, formatter).show();

Reply via email to