summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--public/regform.js36
-rw-r--r--views/layout.erb1
2 files changed, 23 insertions, 14 deletions
diff --git a/public/regform.js b/public/regform.js
index 42bbd58..a74d087 100644
--- a/public/regform.js
+++ b/public/regform.js
@@ -1,19 +1,29 @@
-$(function() {
+function fetch(url, id) {
+ var req = new XMLHttpRequest();
+ req.onload = function() {
+ var element = document.getElementById(id);
+ var node = document.createElement("div");
+ node.innerHTML = this.response;
+ element.appendChild(node);
+ };
+ req.open("GET", url);
+ req.send();
+}
+
+window.onload = function() {
var num_members = 0;
var num_songs = 0;
- $('#add-member-button').click(function(event) {
+ var add_member_button = document.getElementById('add-member-button');
+ var add_song_button = document.getElementById('add-song-button');
+
+ add_member_button.onclick = function() {
num_members += 1;
- $.get('member/new/' + num_members, function(data) {
- $('#form-members').append(data);
- });
- });
+ fetch('member/new/' + num_members, 'form-members');
+ };
- $('#add-song-button').click(function(event) {
+ add_song_button.onclick = function() {
num_songs += 1;
- $.get('song/new/' + num_songs, function(data) {
- $('#form-songs').append(data);
- });
- });
-
-});
+ fetch('song/new/' + num_songs, 'form-songs');
+ };
+};
diff --git a/views/layout.erb b/views/layout.erb
index eb1d803..a8fc171 100644
--- a/views/layout.erb
+++ b/views/layout.erb
@@ -2,7 +2,6 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="<%= url('/styles.css') %>">
- <script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="<%= url('/regform.js') %>"></script>
<meta charset="UTF-8">
<title>Norsk Urskog 2015 - Påmeldingsskjema for band</title>