无法遍历音节并将其取回我的CMS

时间:2018-06-25 12:43:07

标签: javascript jquery

我似乎无法遍历syllables,而我对word做的事情却完全相同。但是,这行得通,怎么办?

我的JSON:

{
"main_object": {
"id": "new",
"getExerciseTitle": "Example",
"language": "nl_NL",
"application": "lettergrepen",
"main_object": {
  "title": "Example",
  "language": "nl_NL",
  "exercises": [
    {
      "word": "espresso",
      "syllables": [
        "es",
        "presso",
        "",
        ""
      ]
    }
  ]
},
"dataType": "json"
 }
}

我的syllables循环:

  var exerSyll = json.main_object.main_object.exercises;

$.map(exerSyll, function(exerSyll, s) {
  $(".syllable" + s).val(exercise.syllables)
});

我的word循环确实有效:

var exercise = json.main_object.main_object.exercises;

$.map(exercise, function(exercise, i) {
 $("#addOpdracht").click();
 $(".exerciseGetWordInput_" + i).val(exercise.word) 

});

应该在其中附加syllables的地方:

 function getWordPartInput(id, cValue){
  cValue = cValue || '';
  var wpInput = $('<input/>', {
 'class': 'form-group form-control syllable',
 'type': 'text',
 'value': cValue,
 'placeholder': 'Syllables',
'name': 'Syllablescounter['+ SyllablesID++ +']'
 });
  return wpInput;
}

0 个答案:

没有答案