Reputation: 93
I have a problem with attaching an onclick event with an appended anchor. When I click on a row it is not giving me the iterative id.
for (var i = 0; i <= oRes.projects.length; i++) {
jQuery('<a/>', {
href: "#_",
html: oRes.projects[i]['project_name'] + "<span>" + oRes.projects[i]['project_duration'] + "</span>" + i,
class: "setup-button projectItems",
"data-role": "button",
"data-iconpos": "left",
"data-projectId": oRes.projects[i]['project_id'],
"click": function() {
alert(i);
}
}).appendTo('#myprojectList');
$('#myprojectList a').button();
}
Upvotes: 0
Views: 75