我想通过onclick将数据附加到jquery Modal并将数组传递给函数正在创建问题。我的代码如下: -
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
当我点击它时,返回以下内容而不是传递数组。请帮助我?
[object Object],[object Object],[object Object]
答案 0 :(得分:2)
ttlpndordsdata
正在转换为属性事件处理程序参数中的字符串。使用.on()
$('#totalpendingtestorders')
.on("click", "a.count", function() {
opulateWidgetInfo(ttlpndordsdata)
})