[Html-widget] Re: repeatable element

Mario Minati mario.minati at googlemail.com
Tue Mar 20 18:54:43 GMT 2007


Am Dienstag 20 März 2007 19:35 schrieb Carl Franks:
> On 20/03/07, Carl Franks <fireartist at gmail.com> wrote:
> > I had a go at the repeatable element last week, and got it working,
> > but came up against a show-stopper. I didn't have the time to bring it
> > to the list for further discussion.
> >
> > Basically, it works fine with javascript, but not the non-JS version.
> >
> > For the non-JS version to work, the 'Add Another X' button needs to be
> > a submit button - a plain 'button' won't submit the form, even with
> > type="submit" set.
> > However, for most form layouts, this means the 'Add Another X' button
> > will be *before* the "main" form submit button in the markup.
> > So, if the user clicks one of the buttons it works fine, but if the
> > user presses 'enter', the browser would submit the form using the
> > first submit button found in the markup - which for us is the wrong
> > button.
> > I've tried giving the 'Add Another X' button a higher 'tabindex' value
> > than the main submit button, but it makes no difference when 'enter'
> > is pressed.
>
> Can anyone spell "hack"?
> ;)
>
> I've managed to get it working for both JS and non-JS - but it ain't
> pretty!
>
> I had to add yet another button, before the 'Add Another X' button.
> This one is set to type="image", with the src pointing to a 1x1
> transparent png, so it's almost invisible.
> It has style="display: none" so it really is invisible for everyone
> with CSS switched on.
> And it has tabindex="-1" so it never receives focus.

H-A-C-K

> Now, if a user presses 'enter' anywhere in the form, this button is
> instead submitted.
> The only problem is that a name/value isn't returned for this new
> button - so you have to set indicator() to some hidden field that you
> know will always be there.
> Luckily, the repeatable implementation uses a hidden 'count' field,
> which is always true. Though I admit, it's not that nice to have to
> refer to that in your form definition.
>
> Mario, if I get some time tomorrow to clean this all up, I will.
> Otherwise I'll just tarball it up and post it to the list.

Take your time, I'll first digest my unicode probs ;-)

Greets,
Mario



More information about the Html-widget mailing list