lundi 4 janvier 2016

Ember controller length test not functioning as intended

I've inherited a project using Ember 1.0 and I'm new to Ember. There's an issue in the code where the length test is not functioning as intended.

Chat.MessagesController = Ember.ArrayController.extend({
    messageAdded: function(m) {
        if (this.get('length') > 0) {
            $('#chat').removeClass('empty-of-messages');
            $(document).trigger('chat_on');
        }
    }.observes('content.@each')
});

When messageAdded fires, the length is always one less than what's expected. Why is this?

I can add other pieces of the code if it's helpful. Please let me know generally what you'd be looking for. Thanks!




Aucun commentaire:

Enregistrer un commentaire