Created
March 29, 2010 18:22
-
-
Save dandean/348208 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.__doPostBack = window.__doPostBack.wrap(function(original) { | |
| var name = arguments[1], | |
| argument = arguments[2] || "", | |
| // Convert name to ID. Strip extranious garbage off of the end. | |
| id = name.replace(/\$/g, '_').replace(/_ctl00$/, ''), | |
| element = $(id); | |
| if (element.hasClassName("ajax")) { | |
| // Make the ajax request. | |
| var form = element.up("form"), | |
| // Inject target and argument into data | |
| data = Object.extend(form.serialize(true), { | |
| "__EVENTTARGET": name, | |
| "__EVENTARGUMENT": argument | |
| }); | |
| new Ajax.Request(form.action, { | |
| params: data, | |
| onSuccess: function(xhr) { | |
| document.fire("xhr:success", { | |
| transport: xhr, | |
| source: name | |
| }); | |
| } | |
| }); | |
| } else original(name, argument); | |
| }); | |
| /* | |
| TODO: | |
| - Observe "submit" on the page form. | |
| -- If the source is an input of type SUBMIT, IMAGE or BUTTON, or a BUTTON | |
| -- and the source hasClassName("ajax"), stop the event and post async. | |
| - Auto-process response. Convert resonse to JSON on server side. | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fucking off dotnet!!!!!