Skip to content

Instantly share code, notes, and snippets.

@yorzi
Created July 1, 2011 14:23
Show Gist options
  • Save yorzi/1058637 to your computer and use it in GitHub Desktop.
Save yorzi/1058637 to your computer and use it in GitHub Desktop.
signInModal cs.js.coffee
signInModal = ->
console.log("in modal 01")
$( "#sign_in_modal" ).dialog
modal: true
autoOpen: $("body").hasClass("show_login")
resizable: false
minWidth: 400
$("a.login, a#login_link").click =>
console.log("in modal 02")
alert "Login Clicked!!!"
$( "#sign_in_modal" ).dialog("open")
$('#sign_in_modal form input[type="submit"]').unbind("click").click =>
console.log("in modal 03")
form = $("#sign_in_modal form")
form.find("img").show()
form.find("input[type='submit']").attr("disabled","disabled")
form.find("input[type='submit']").addClass("inactive")
$.ajax
url: form.attr("action") + ".js"
type: "post"
dataType: "json"
data: form.serialize()
complete: ->
form.find("img").hide()
form.find("input[type='submit']").removeAttr("disabled")
form.find("input[type='submit']").removeClass("inactive")
success: (data, response) ->
form.find(".sign_in_flash.notice").show()
window.location = data.redirect
error: ->
form.find(".sign_in_flash.error").show()
beforeSend: ->
form.find(".sign_in_flash").hide()
false
$ ->
signInModal
alert "ready!! go!!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment