Event listeners for dynamic content in evently

301 Views Asked by At

I am generating a dynamic html table. One of the columns in the table has a clickable image (a href). For testing, I have also created a static table, with similar structure as the dynamic table, in the same div.

I have defined a selectors/a/click.js event handler, which works fine for the links in the static table, but not in the dynamic table.

It seems that, since the table is dynamically generated, evently is not attaching any event handlers to it.

Could somebody suggest a workaround for this?

2

There are 2 best solutions below

0
On BEST ANSWER

I found a workaround: use live instead of bind in the evently library:

cd vendor/couchapp/_attachments
cat jquery.evently.js  | sed -e 's!\.bind(!.live(!'

I'll try to push this upstream into evently.

0
On

Alternatively, you may lay your events in a following way:

table/<event>/selectors/a/click.js

(where is event responsible for filling your dynamic table, for example _changes). This ensures that the events are being bound after table is generated.