0

I came across a strange scenario. I used jquery's data function to store a row element with several td columns and some event handlers on those columns. When I try to retrieve that row element in another function I don't find the events in the data('events') on that element.

Do the event handlers get skipped while using jquery's data function?

Prassy
  • 1

1 Answers1

0

You may be confusing data() with attr() and prop() potentially see the jquery docs or prop vs data or prop vs attr.

I can't think of a context where I would use data() to handle events. I use on() by preference to set event handlers, and unbind() to remove them afterwards.

Using the html attribute onclick="doSomeJavascriptThing();" is not a very jQuery way of solving the problem. Inline javascript is probably considered a bit dirty these days.

Community
  • 1
  • 1
Tim Ogilvy
  • 1,923
  • 1
  • 24
  • 36