Skip to content

Instantly share code, notes, and snippets.

@leomelzer
Created July 6, 2009 08:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
// http://tore.darell.no/posts/buttons_what_buttons
// prototypejs
/*
document.observe('dom:loaded', function(){
$$('form.button-to').each(function(form){
var link = new Element('a', {href:'#', 'class':'button-to'});
link.update(form.down('input[type=submit]').value);
link.observe('click', function(e){
e.stop();
form.submit();
});
form.insert({after:link});
form.hide();
});
});
*/
// jquery 1.4, something like this
(function($) {
$('form.button-to').each(function() {
$('<a/>', {
class : 'button-to',
href : '#',
text : $('input[type=submit]', this).val(),
click : function(e) {
e.preventDefault();
form.submit();
}
}).insertAfter(this).hide();
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment