I want to append data to a jquery Modal through onclick and passing array into a function is creating problem. My code is as follows:-
var ttlpndordsqnty = topBarData['ttlpndngordrs'].length;
var ttlpndordsdata = topBarData['ttlpndngordrs'];
$('#totalpendingtestorders').empty();
$('#totalpendingtestorders').append('<a onClick="populateWidgetInfo(\''+ttlpndordsdata+ '\')" class="count red" data-toggle="modal" data-target="#totalpndgordModal"><label >' +ttlpndordsqnty+ '</label></a>');
function populateWidgetInfo(data)
{
console.log(data);
} //end function
when i click on this then the following is returned instead of array passed. Kindly help me?
[object Object],[object Object],[object Object]
console.log(ttlpndordsdata )give?$('#totalpendingtestorders').append('<a onClick="populateWidgetInfo(\''+ttlpndordsdata+ '\')" class="count red" data-toggle="modal" data-target="#totalpndgordModal"><label >' +ttlpndordsqnty+ '</label></a>');your ttlpndordsdata converts to string and passed to your function once you click. That's why your log is[object Object],[object Object],[object Object]atag object and assign it'sonClickmethod properly through JS and then use.appendChild()to append it to it's parent.