Search code examples
derbyjs

How to clear a value on page load for derbyjs


Just out of curiosity if I have a chat application with an unread message counter...

How do I reset that counter?

Simply put, when User A writes a message, B increments there unread counter. When B is on the message page, I would like to reset that counter each refresh of the messages (it is running on subscribe).

Any ideas?


Solution

  • Actually it was pretty simple.

    You can write the following code in your html:

    {{yourMethodName();}}
    

    Then in your server you write some code:

    app.proto.yourMethodName = function(){
      //Clear data
      this.model.del("yourdata.count");
      //similar to: this.model.set("yourdata.count",0);
    }
    

    Super simple.... Updated based off of Aleksey