Question to $(object).live('click', function)

Question to $(object).live('click', function)

astoasto Posts: 2Questions: 0Answers: 0
edited April 2013 in General
Hi,

I have a question to correct usage of live() method. To catch a click event on image in table row I use the following code, which works fine for me.

[code]
$('.dataTable tbody td img').live('click', function (event) {
var v = event.target;
[/code]
Now I try to use the front-end frameworks bootstrap and font-awesome and display images in table rows by using the following syntax:

[code]
"fnRender": function (oObj) {
return ''
[/code]
Instead of the frameworks uses to show images. To catch the onclick event, I try

[code]
$('.dataTable tbody td i').live('click', function (event) {
var v = event.target;
[/code]
but this didn't work. Any idea?

Thanks in advanced
Arne

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    $().live() was deprecated by jQuery. YOu should use $().on() instead now.

    [code]
    $('.dataTable tbody').on('click', 'td i', function () {... } );
    [/code]

    should do it. If it doesn't please link to a test page showing the problem.

    Allan
  • astoasto Posts: 2Questions: 0Answers: 0
    Hi Allan,

    works perfectly, many thanks.

    Arne
This discussion has been closed.