Skip to content

Commit

Permalink
Added answer limit for each question in quest creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
straumer committed Nov 5, 2019
1 parent e51acca commit e556eb8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/assets/v2/js/pages/quests.new.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@

$(document).ready(function() {
const QUESTIONS_LIMIT = 6;
const ANSWERS_LIMIT = 10;

$(document).on('form#newkudos', 'submit', function(e) {
// e.preventDefault();
// console.log($(this).formdata);
// alert('hi');

});

$(document).on('click', '.add_answer', function(e) {
e.preventDefault();

if ($(this).parents('.question').children('span').length >= ANSWERS_LIMIT) {
alert('The number of answers for each question are limited to ' + ANSWERS_LIMIT);
return;
}

var dupe_me = $(this).parents('.form-group').find('span:last');
var clone = dupe_me.clone();

Expand Down

0 comments on commit e556eb8

Please sign in to comment.