0
var fieldArray = [];
var fields = {{ json_encode(Config::get('planner.'.$viewType.'_view_jobs')) }};
for(var i in fields) {
    fieldArray.push([i, fields [i]]);
}
var outDiv = document.createElement('div');

for (var x = 0; x < fieldArray.length; x++) {
    container[x] = document.createElement('div');
    label[x] = document.createElement('div');
    label[x].className = "label-job control-label";
    $(label[x]).text(fieldArray[x][0]);
    value[x] = document.createElement('div');
    value[x].className = "label-value numeric";
    eval("$(value[x]).text(event." + fieldArray[x][1] + ");");
    container[x].appendChild(label[x]);
    container[x].appendChild(value[x]);
}
outDiv.appendChild(container);

element.attr("data-toggle", "popover");
element.attr("data-content", $(outDiv).text());
element.append("<br />");

Hi All, this is my code. I am trying to append multiple 'label', 'value' into 'container'. Then append multiple 'container' into 'OutDiv'. However I got this error.

fieldArray = [["Ttl Job", "ttl_job"], ["Ctr Job", "ctr_job"]];

label, value, container is the var that store my createElementDiv I really need your help. Thanks.

4
  • What is fieldArray, container, label, and value. please update you question. And of course don't forget to format your code. Sep 8, 2016 at 4:46
  • @mortezaT: I have edited my code and specifies the fieldArray, container, label and value.
    – Kassie Teo
    Sep 8, 2016 at 6:59
  • Please add your error message and stack trace too. Sep 10, 2016 at 4:15
  • I solved the problem. By moved outDiv.appendChild(container); into the for loop. Then change it to outDiv.appendChild(container[x]);
    – Kassie Teo
    Sep 14, 2016 at 10:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.