diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2015-10-20 23:00:27 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2015-10-28 21:32:16 +0100 |
commit | c69ab8c2bc8dfa59070249dd434219d83a792dbc (patch) | |
tree | 50724df6b9d9a7a4c9b547c29c6aae8804fc4846 | |
parent | 3d2952ddd2718561d6f29a8bf2cc0109c913b9ae (diff) | |
download | norsk-urskog-registrations-c69ab8c2bc8dfa59070249dd434219d83a792dbc.tar.gz norsk-urskog-registrations-c69ab8c2bc8dfa59070249dd434219d83a792dbc.tar.bz2 norsk-urskog-registrations-c69ab8c2bc8dfa59070249dd434219d83a792dbc.zip |
Drop dependency on jQuery.
Hopefully XMLHttpRequest is supported and standardised enough to work accross browsers now.
-rw-r--r-- | public/regform.js | 36 | ||||
-rw-r--r-- | views/layout.erb | 1 |
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> |