Yeah, it does sound like that's the case - here's an alternate
solution that does not assume that the form is the parent:

$("<a href='' class='button'>ButtonText</a>")
 .click(function() { $(this).parents("form")[0].submit(); return false; })
 .insertAfter('input:submit');

--John

On 12/27/06, Yehuda Katz <[EMAIL PROTECTED]> wrote:
> John's solution and mine assume that your link is a direct child of the
> form. Is it?
>
> -- Yehuda
>
>
> On 12/27/06, Phil Oye < [EMAIL PROTECTED]> wrote:
> > None of the proposed solutions are working for me. Now I'm wondering
> > if it is a markup problem, or something.
> >
> > Bander's solution:
> > > I'll bet it'll work with $(this).prev().click().
> >
> > Nothing happens.
> > Presumably, because it attempts to go the original href ("#"), not
> > the newly created onclick event?
> >
> >
> > Mike's solution:
> > > $(':submit').each(function() {
> > >     var form = this.form;
> > >     var b = $('<a href="#" class="button">Button Text</a>");
> > >     $(this).after(b).hide();
> > >     b.click(function() {
> > >         form.submit();
> > >         return false;
> > >     });
> > > });
> >
> > In FireBug, I get:
> > form.submit is not a function.
> > (Also, there was a typo in the close quote on line 3)
> >
> >
> > Yehuda's solution:
> > > $('[EMAIL PROTECTED]').after("<a href='#'
> > > class='button'>ButtonText</a>").next().click(function()
> > > { this.parentNode.submit(); })
> > >
> > > assuming the button and link are directly under the form.
> >
> > In FireBug, I get this error:
> > this.parentNode.submit is not a function.
> >
> >
> > John's solution:
> > > $("<a href='' class='button'>ButtonText</a>")
> > >   .click(function() { this.parentNode.submit(); return false; })
> > >   .insertAfter('input:submit');
> >
> > I get the same error:
> > this.parentNode.submit is not a function
> > It then refreshes the page.
> >
> >
> > Any ideas? Markup problem?
> >
> > Thanks,
> > p.
> >
> >
> > On 28 Dec 2006, at 11:40 AM, John Resig wrote:
> >
> > > Or, a similar, but different, way:
> > >
> > > $("<a href='' class='button'>ButtonText</a>")
> > >   .click(function() { this.parentNode.submit(); return false; })
> > >   .insertAfter('input:submit');
> > >
> > > --John
> > >
> > > On 12/27/06, Yehuda Katz <[EMAIL PROTECTED]> wrote:
> > >> $('[EMAIL PROTECTED]').after("<a href='#'
> > >>
> class='button'>ButtonText</a>").next().click(function() {
> > >> this.parentNode.submit(); })
> > >>
> > >> assuming the button and link are directly under the form.
> > >>
> > >> -- Yehuda
> > >>
> > >> On 12/27/06, Mike Alsup < [EMAIL PROTECTED]> wrote:
> > >>>> Can you give me a pointer to fix this?
> > >>>
> > >>> $(':submit').each(function() {
> > >>>     var form = this.form;
> > >>>     var b = $('<a href="#" class="button">Button Text</a>");
> > >>>     $(this).after(b).hide();
> > >>>     b.click(function() {
> > >>>         form.submit();
> > >>>         return false;
> > >>>     });
> > >>> });
> > >
> > > _______________________________________________
> > > jQuery mailing list
> > > [email protected]
> > > http://jquery.com/discuss/
> >
> > _______________________________________________
> > jQuery mailing list
> > [email protected]
> > http://jquery.com/discuss/
> >
>
>
>
> --
> Yehuda Katz
> Web Developer | Wycats Designs
> (ph)  718.877.1325
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
>

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to