From b65549d1e2f7df62c9f941ed92b00759351e0c5f Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 9 Oct 2015 21:04:00 +0200 Subject: 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. --- public/regform.js | 56 ++++++++----------------------------------------------- 1 file changed, 8 insertions(+), 48 deletions(-) (limited to 'public') 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( - '
' + - '

Medlem nr. '+num_members+'

' + - '
' + - ' ' + - ' ' + - '
' + - '
' + - ' ' + - ' ' + - '
' + - '
' + - ' ' + - ' ' + - '
' + - '
' - ) + $.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( - '
' + - '

Låt nr '+num_songs+'

' + - '
' + - ' ' + - ' ' + - '
' + - '
' + - ' ' + - ' '+ - '
' + - '
' + - ' ' + - ' '+ - '
' + - '
' + - ' '+ - ' ' + - '
' + - '
' + - ' '+ - ' ' + - '
' + - '
' + - ' '+ - ' ' + - '
' + - '
' - ) + $.get('song/new/' + num_songs, function(data) { + $('#form-songs').append(data); + }); }); }); -- cgit v1.2.3