Skip to content

Commit

Permalink
move the triggering of the ajax:before event to allow the caller to m…
Browse files Browse the repository at this point in the history
…odify the DOM before the form is serialized

also skip everything early on if the event was stopped
  • Loading branch information
brianmario committed May 17, 2010
1 parent 900eefa commit 1752d4c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rails.js
Expand Up @@ -2,6 +2,9 @@ document.on("dom:loaded", function() {
function handleRemote(element) {
var method, url, params;

var event = element.fire("ajax:before");
if (event.stopped) return false;

if (element.tagName.toLowerCase() === 'form') {
method = element.readAttribute('method') || 'post';
url = element.readAttribute('action');
Expand All @@ -12,9 +15,6 @@ document.on("dom:loaded", function() {
params = {};
}

var event = element.fire("ajax:before");
if (event.stopped) return false;

new Ajax.Request(url, {
method: method,
parameters: params,
Expand Down

5 comments on commit 1752d4c

@brianmario
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about the re-commit of this diff, didn't realize you'd already pulled the other one or I would have made it a separate commit ;)

@josh
Copy link
Contributor

@josh josh commented on 1752d4c May 17, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fast

@josh
Copy link
Contributor

@josh josh commented on 1752d4c May 17, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shit, my bad. I misread the diff. event.stop is for ajax:before. reverting...

@brianmario
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josh
Copy link
Contributor

@josh josh commented on 1752d4c May 17, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. we're all good now.

Please sign in to comment.