Created
February 23, 2015 19:38
-
-
Save backy22/0fe9418f6a961ec43432 to your computer and use it in GitHub Desktop.
This file contains 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
$(function() { | |
var house = { | |
"dan1": "根津", | |
"dan2": "渋谷", | |
"dan3": "外苑前", | |
"dan4": "神楽坂" | |
}; | |
// 表示するフォームは 'dialog-form' という ID で定義します。 | |
$("#dialog-form1").dialog({ | |
autoOpen: false, | |
height: 350, | |
width: 450, | |
modal: true, | |
buttons: { // ダイアログに表示するボタンと処理 | |
"送信": function() { | |
var $form1=$(this).find('form'); | |
$.ajax({ | |
url: $form1.attr('action'), | |
type: $form1.attr('method'), | |
data: $form1.serialize(), | |
success:function(result, textStatus, xhr){ | |
$form1[0].reset(); | |
alert("送信しました"); | |
$("#dialog-form1").dialog("close"); | |
} | |
}); | |
}, | |
"閉じる": function() { | |
$(this).dialog("close"); | |
}, | |
}, | |
}); | |
// 「開く」ボタンがクリックされたらダイアログを表示 | |
$(".open1").click(function() { | |
$("#dialog-form1").dialog("open"); | |
var dan = $(this).data("dan"); | |
switch (dan){ | |
case "dan1": | |
$("#userhouse1").val(house["dan1"]); | |
break; | |
case "dan2": | |
$("#userhouse1").val(house["dan2"]); | |
break; | |
case "dan3": | |
$("#userhouse1").val(house["dan3"]); | |
break; | |
case "dan4": | |
$("#userhouse1").val(house["dan4"]); | |
break; | |
} | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment