動的に生成された入力ボタンは、関数を呼び出している場合があります (関数は の外の同じページに表示されます$(document).ready()
) がTypeerror
、関数が存在しない場合があります。
ではshiftRight()
、ボタンを作成し、そのクリックで、引数を指定して関数をshiftLeftButton
呼び出しています。shiftLeft()
は shiftLeftButtons
複数あります。shiftLeftButton
いくつかの引数を指定して関数を呼び出す場合とそうでない場合があります。
これをデバッグしようとし、この問題を検索しましたが、解決策が得られませんでした。
function shiftRight(leftButtonNo) {
//Creating a hidden field in the form
if(!$("#innerQuestionListDiv"+leftButtonNo).doesExist()){
if(!$("#clonedDiv"+leftButtonNo).doesExist()){
$('#TestSetFormId').append('<input type="hidden" name="questionIdsForTestSet" value="'+ leftButtonNo+'" id="questionIdForTestSet'+ leftButtonNo+'" />');
***//Creating shift left button
var $shiftLeftButton= $('<input/>').attr({
type: 'button', name:'shiftLeft',
id:'shiftLeftId'+leftButtonNo ,
value:'<--'+leftButtonNo+'',
onclick:'shiftLeft('+leftButtonNo+')'
});***
//Getting clone of the div
$cloneQuestionDiv=$("#div"+leftButtonNo).clone();
***//Appending it to a cloned div
$cloneQuestionDiv.append($shiftLeftButton);***
$cloneQuestionDiv.attr('id', 'clonedDiv'+leftButtonNo);
$cloneQuestionDiv.prependTo('#existingQuestionDiv');
$("#list"+leftButtonNo).hide();
}else{
alert("You already added this question");
$("#list"+leftButtonNo).hide();
}
}else{
alert("Question already exist into the Test Set");
$("#list"+leftButtonNo).hide();
return;
}
}
*function shiftLeft(rightButtonNo){
//Removing hidden field in the form
$("#questionIdForTestSet"+rightButtonNo).remove();
$("#clonedDiv"+rightButtonNo).remove();
if($("#list"+rightButtonNo).doesExist()){
$("#list"+rightButtonNo).show();
}
$(this).hide();
}*