Great technique, Karl!



On 6/10/07, Karl Rudd <[EMAIL PROTECTED]> wrote:

This has come up a number of times.

My suggestion is to use a "proxy link". When the link is pressed it
"clicks" the button. That way you don't need to modify any of the
backend code, and it will work without JavaScript on.

Something like this:

$(function() {
       $('input.proxy').each( function() {
               var input = $(this);
               $('<a href="#">' + this.value + '</a>')
                       .attr( 'class', this.className )
                       .insertBefore( this)
                       .click( function() {
                               input.click();
                               return false;
                       });
               input.hide();
       });
});

The initial HTML looks like this:

   <input class="proxy" type="submit" value="Save">

After jQuery has done it's thing it look like this:

   <input type="submit" class="proxy" value="Save" style="display:none">
   <a href="#" class="proxy">Save</a>

And voila, you have a link you can style to your heart's content the
functions just like the normal submit button.

Reply via email to