ここにjsfiddleがあります。これを使用して、アプリケーションの基本的なデモと私が抱えている問題を確認できます。
フィドルを開くときは、以下の手順に従ってください。
- 「Open Grid」リンクが表示されます。リンクをクリックして、「True or False」または「Yes or No」ボタンを選択します。
- いずれかのボタンを選択すると、その下に回答ボタンが表示されます。
- [質問を追加] ボタンをクリックすると、下の表に表の行が追加されます。
- 追加された行に問題があります。追加された行内の「Open Grid」リンクをクリックしていずれかのボタンを選択すると、その下にある対応する回答ボタンが消えることがわかります。それらは消えないように表示する必要があります。
だから私の質問は、ユーザーが追加された行の「Open Grid」リンクをクリックしたときに、対応する回答ボタンが追加された行に表示されるように、誰でもデモを変更できるかということです。
おそらくこのコード内に問題があると思いますが、よくわかりません:
var count = 0;
var plusbutton_clicked;
var gQuestionIndex = 0;
function insertQuestion(form) {
var context = $('#optionAndAnswer');
var currenttotal = context.find('.answerBtnsOn').length;
var $tbody = $('#qandatbl > tbody');
var $tr = $("<tr class='optionAndAnswer' align='center'>");
var $td = $("<td class='extratd'>");
var $options = $("<div class='option'>1. Option Type:<br/></div>");
var $answer = $("<div class='answer'>3. Answer:<br/></div>");
gQuestionIndex++;
$('.gridTxt', context).each(function() {
var $this = $(this);
var $optionsText = $("<input type='text' class='gridTxtRow maxRow' readonly='readonly' />").attr('name', $this.attr('name') + "[]").attr('value', $this.val()).appendTo($options).after("<span href='#' class='showGrid'>[Open Grid]</span>");
$questionType = $this.val();
});
var $this, i = 0,
$row, $cell;
$('#optionAndAnswer .answers').each(function() {
$this = $(this);
if (i % 7 == 0) {
$row = $("<tr/>").appendTo($answer);
$cell = $("<td/>").appendTo($row);
}
var $newBtn = $(("<input class='answerBtnsRow answers' type='button' style='display:%s;' onclick='btnclick(this, " + gQuestionIndex + ");' />").replace('%s', $this.is(':visible') ? 'inline-block' : 'none')).attr('name', "value[" + gQuestionIndex + "][]").attr('value', $this.val()).attr('class', $this.attr('class')).attr('id', $this.attr('id') + 'Row');
$newBtn.appendTo($cell);
i++;
});
$tr.append($td);
$td.append($options);
$td.append($answer);
$tbody.append($tr);
count++;
$('#optionAndAnswer .answerBtns').hide();
$('#optionAndAnswer .answerBtns').removeClass('answerBtnsOn').addClass('answerBtnsOff');
updateAnswer($answer, gQuestionIndex);
}
ありがとう