anchor tag onclick event not working

anchor tag onclick event not working

ilatineilatine Posts: 20Questions: 2Answers: 0
edited July 2015 in DataTables 1.10

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#

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    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 the window scope. However openModal() 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

  • ilatineilatine Posts: 20Questions: 2Answers: 0

    Thanks!

This discussion has been closed.