anchor tag onclick event not working
anchor tag onclick event not working
ilatine
Posts: 20Questions: 2Answers: 0
Hello,
I am trying to create a onclick event in my link in a column in my datatable but it's not working. What am I doing wrong? Thanks!
'''for(var i =0; i < data.d.results.length; i++)
''' {
''' bldRow.row.add([ data.d.results[i].Created, "<a href='#' onClick='openModal();return false;'>"+data.d.results[i].Title+"</a>",+data.d.results[i].NumCommentsId]).draw();
''' }
Here's a link:
http://www.isogunro.com/default.aspx#
This discussion has been closed.
Replies
Hi,
I'm getting a timeout error at the moment from the Ajax request so I can't say for certain, but I think the issue is that DOM0 events such as
openModal()
execute in thewindow
scope. HoweveropenModal()
is a local function and does not have global scope so it can't be executed. You should be getting an error in the console about that.My recommendation is always to stay away from DOM0 events. Use jQuery events like this example instead.
Allan
Thanks!