Skip to content

Instantly share code, notes, and snippets.

@greatseth
Created November 22, 2008 00:25
Show Gist options
  • Save greatseth/27706 to your computer and use it in GitHub Desktop.
Save greatseth/27706 to your computer and use it in GitHub Desktop.
// form posts to a different url
// change 'subscribe' callback to 'unsubscribe'
// change loading
var form_element = obj.down('form');
var onsubmit = form_element.getAttribute('onsubmit').toString();
var onloading = 'onLoading:function(request){subscription_loading_unsubscribed(\'' + container_id + '\')}';
var new_onsubmit = onsubmit.gsub(/'\/subscriptions\/[\d]+'/, "'\/subscriptions'").gsub(/\{unsubscribe\(/, '{subscribe(').gsub(/onLoading:function\(request\)\{[^}]+\}/, onloading);
form_element.setAttribute('onsubmit', new_onsubmit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment