diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2015-10-09 21:04:00 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2015-10-09 21:04:00 +0200 |
commit | b65549d1e2f7df62c9f941ed92b00759351e0c5f (patch) | |
tree | efa6c513d8c251f0fd869e73c34dfa9c6d1686d8 /public | |
parent | bfc6d9a6ceed3a2ee9a38a1afa4dffec972eca83 (diff) | |
download | norsk-urskog-registrations-b65549d1e2f7df62c9f941ed92b00759351e0c5f.tar.gz norsk-urskog-registrations-b65549d1e2f7df62c9f941ed92b00759351e0c5f.tar.bz2 norsk-urskog-registrations-b65549d1e2f7df62c9f941ed92b00759351e0c5f.zip |
Use ajax to get member and song subforms.
This instead of hard coding them in javascript. We will need the forms as ruby/erb
templates anyways so no need to keep them two places.
Diffstat (limited to 'public')
-rw-r--r-- | public/regform.js | 56 |
1 files changed, 8 insertions, 48 deletions
diff --git a/public/regform.js b/public/regform.js index e620b04..42bbd58 100644 --- a/public/regform.js +++ b/public/regform.js @@ -2,58 +2,18 @@ $(function() { var num_members = 0; var num_songs = 0; - $('#add-member-button').click(function() { + $('#add-member-button').click(function(event) { num_members += 1; - $('#form-members').append( - '<div class="member-info">' + - ' <h4>Medlem nr. '+num_members+'<input type="button" name="delete" data-member="'+num_members+'" class="delete-member-button" value="X"></h4>' + - ' <div class="field text required">' + - ' <label for="band-member-'+num_members+'-name">Navn:</label>' + - ' <input type="text" id="band-member-'+num_members+'-name" name="band[members]['+num_members+'][name]">' + - ' </div>' + - ' <div class="field text optional">' + - ' <label>Instrument:</label>' + - ' <input type="text" name="band[members]['+num_members+'][instrument]">' + - ' </div>' + - ' <div class="field class optional">' + - ' <label>Alder:</label>' + - ' <input type="text" name="band[members]['+num_members+'][age]" size="3" pattern="[0-9]{1,2}">' + - ' </div>' + - '</div>' - ) + $.get('member/new/' + num_members, function(data) { + $('#form-members').append(data); + }); }); - $('#add-song-button').click(function() { + $('#add-song-button').click(function(event) { num_songs += 1; - $('#form-songs').append( - '<div class="song-info" id="song-'+num_songs+'-info">' + - ' <h4>Låt nr '+num_songs+'<input type="button" id="delete-song-'+num_songs+'" class="delete-song" value="X"></h4>' + - ' <div class="field text required">' + - ' <label for="band-song-'+num_songs+'-title">Tittel:</label>' + - ' <input type="text" id="band-song-'+num_songs+'-title" name="band[songs]['+num_songs+'][title]">' + - ' </div>' + - ' <div class="field text optional">' + - ' <label for="band-song-'+num_songs+'-time">Lengde:</label>' + - ' <input type="text" pattern="[0-9]{2}:[0-9]{2}" title="Spilletid i min:sek (mm:ss)" id="band-song-'+num_songs+'-time" name="band[songs]['+num_songs+'][time]" size="6">'+ - ' </div>' + - ' <div class="field text optional">' + - ' <label for="band-song-'+num_songs+'-isrc">ISRC-kode:</label>' + - ' <input type="text" title="Dersom låten har vært utgitt før har den en ISRC-kode. Om du vet den så oppgi den her." id="band-song-'+num_songs+'-isrc" name="band[songs]['+num_songs+'][isrc]" size="11">'+ - ' </div>' + - ' <div class="field textarea required">' + - ' <label for="band-song-'+num_songs+'-performers">Utøvere:</label>'+ - ' <textarea cols="40" rows="5" id="band-song-'+num_songs+'-performers" name="band[songs]['+num_songs+'][performers]" title="Fullt navn (ingen pseudonymer) på alle som er med på denne innspillingen."></textarea>' + - ' </div>' + - ' <div class="field textarea required">' + - ' <label for="band-song-'+num_songs+'-composers">Opphavsmenn:</label>'+ - ' <textarea cols="40" rows="5" id="band-song-'+num_songs+'-composers" name="band[songs]['+num_songs+'][composers]" title="Fullt navn (ingen pseudonymer) på alle som har vært med på å skrive denne låten."></textarea>' + - ' </div>' + - ' <div class="field textarea optional">' + - ' <label for="band-song-'+num_songs+'-notes">Andre merknader:</label>'+ - ' <textarea cols="40" rows="5" id="band-song-'+num_songs+'-notes" name="band[songs]['+num_songs+'][notes]" title="Evt andre ting vi burde vite."></textarea>' + - ' </div>' + - '</div>' - ) + $.get('song/new/' + num_songs, function(data) { + $('#form-songs').append(data); + }); }); }); |