Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:19:33+00:00 2026-06-03T13:19:33+00:00

I started writing coffeescript last week, as I am programming a new Play20 site

  • 0

I started writing coffeescript last week, as I am programming a new Play20 site where coffeescript is the standard. I want to update a getData function in my class every 5 minutes, but the setInterval function does not bind to my class. Only the first time it calls getData, because the ‘this’ object is still reachable, as the setUpdateInterval() function is called from within the constructor.

But after the first call, the setInterval does not have any connection anymore with the Widget instance, and does not know what the this.getData() function is (and how to reach it).

Does someone know how to do it?

Here is my code:

class Widget
  constructor: (@name) ->
    this.setUpdateInterval()

  getData: ->
    console.log "get Data by Ajax"

  setUpdateInterval: (widget) ->
    setInterval( this.getData(), 3000000 )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:19:35+00:00Added an answer on June 3, 2026 at 1:19 pm

    Now here some Javascript magic is required. Reference

    class Widget
      constructor: (@name) ->
        this.setUpdateInterval()
    
      getData: ->
        console.log "get Data by Ajax"
    
      setUpdateInterval: (widget) ->
        callback = @getData.bind(this)
        setInterval( callback, 3000000 )
    

    This will work in almost all browsers (guess which one not), so the
    function will have to be bound differently. Some coffeescript magic:

    callback = => @getData
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new (started today) to writing chrome extensions but need to write
I started writing a small wrapper class to take care of my excel operations:
I have started writing my own WebDAV server class in .NET, and the first
I've started writing a class to model a matrix and the compiler gives me
I had working on a class and started writing everything in the same .cpp
I've started writing a new CUDA application. However I hit a funny detour along
Heyo, Just started writing an assembler for the imaginary computer my class is creating
I started writing functional tests for my rails app today. I use the RESTful
I have started writing a Macro in Visual Studio 2005 like this: Public Sub
I have just installed C# 2008 Express Edition 2008 and started writing code. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.