Skip to content

Automatically update for dynamically added time elements #22

@Globegitter

Description

@Globegitter

I like the idea of just having to initialize $('body').timeago(); one time globally and then it keeps track of everything automatically but that only seems to work in a limited manner.
I know there is $('body').timeago('refresh'); for scenarios I am talking about but I seem to having issue with my ember.js app (see http://emberjs.com ), which also doesn't seem to be too easy to solve on the ember-side alone.
Basically I have a full JS frontend app, which dynamically loads data from an API. And that is where the issue starts: We have a user-profile, which dynamically loads timestamps from the server for posts. Ember.js doesn't seem to have an event-hook for when it populates the 'datetime' attribute.

To cut straight to the chase, would it be possible to implement some observer that automatically keeps track of programatically inserted/changed attributes at an unknown time?
I would obviously be willing to help, but I am also not quite sure how much time I will have available to do this all by myself.

The things I have found so far, if you are interested:
http://darcyclarke.me/development/detect-attribute-changes-with-jquery/
http://stackoverflow.com/questions/4561845/firing-event-on-dom-attribute-change

https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Events/Mutation_events
https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver?redirectlocale=en-US&redirectslug=DOM%2FMutationObserver

http://www.w3.org/TR/DOM-Level-3-Events/

At some of these implementations I am worried about performance (with the setInterval implementation). But in any case, let me know what you think and if I should look a bit more into it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions