-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
49 lines (43 loc) · 1.72 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$(function() {
$("a.nav-link").click(function() {
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top - 56
});
});
$("#nameLookupForm").submit(function(e) {
// Prevent default functionality
e.preventDefault();
// Get the action URL of the form
var actionurl = $(this).find("button").prop("formAction");
// Do our own request and handle the results
$.ajax({
url: actionurl,
type: "POST",
dataType: "json",
data: $("#nameLookupForm").find("input[name=firstName], input[name=lastName]").serialize(),
jsonp: false,
success: function(data) {
$("#numGuestsInput").attr("value", data["numGuests"]);
$("#attendingDay1Check").prop("checked", data["presentForDay1"]);
$("#attendingDay2Check").prop("checked", data["presentForDay2"]);
$("#rsvpEditForm").prop("disabled", false).slideDown();
}
});
});
$("#rsvpEditForm").submit(function(e) {
// Prevent default functionality
e.preventDefault();
// Get the action URL of the form
var actionurl = $(this).find("button").prop("formAction");
// Do our own request and handle the results
$.ajax({
url: actionurl,
type: "POST",
dataType: "json",
data: $("#nameLookupForm, #rsvpEditForm").find("input[name=firstName], input[name=lastName], input[name=numGuests], input[name=presentForDay1], input[name=presentForDay2], input[name=vegetarian]").serialize(),
jsonp: false,
success: function(data) {
}
});
});
});