Skip to content

Commit

Permalink
Cache selector in afterRender function
Browse files Browse the repository at this point in the history
- cache selector in a variable to prevent recomputing it in the function.
  • Loading branch information
buddhamagnet committed Oct 14, 2013
1 parent 2a459b5 commit 0662817
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/client/views/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,16 @@

afterRender: function () {
var self = this;

Countable.live(document.getElementById('user-bio'), function (counter) {
var bioContainer = self.$('.bio-container .word-count');
if (counter.all > 180) {
self.$('.bio-container .word-count').css({color: "#e25440"});
bioContainer.css({color: "#e25440"});
} else {
self.$('.bio-container .word-count').css({color: "#9E9D95"});
bioContainer.css({color: "#9E9D95"});
}

self.$('.bio-container .word-count').text(200 - counter.all);
bioContainer.text(200 - counter.all);

});

Expand Down

0 comments on commit 0662817

Please sign in to comment.