Skip to content

Instantly share code, notes, and snippets.

@momchilov
Created February 13, 2012 13:43
Show Gist options
  • Save momchilov/1817049 to your computer and use it in GitHub Desktop.
Save momchilov/1817049 to your computer and use it in GitHub Desktop.
Sucky javascript.
$(document).ready(function() {
var loginLink = $("a#login");
var loginWindow = $("div#login");
var loginForm = $('#login-form-dialog');
var submitButton = $('#button-logindialog-submit');
$.fn.submitWithAjax = function() {
this.submit(function() {
$.post(this.action, $(this).serialize(), null, "script");
return false;
});
return this;
};
loginLink.click(function () {
loginWindow.html('<%= escape_javascript(render :partial => "checkout/login") %>').dialog(
function() {
submitButton.click(function(){
loginForm.submitWithAjax();
});
}
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment