javascript - Trouble with static properties being undefined in CoffeeScript -
javascript - Trouble with static properties being undefined in CoffeeScript -
so i'm writing coffeescript project , i'm trying create static properties in class. i've been next file in codebase same thing successfully, mine isn't working.
my code
class messages @toggleunreadconversations:()-> # line in question, messages defined # functions property viewonlyunread undefined messages.viewonlyunread = !messages.viewonlyunread @init:-> @viewonlyunread = false
other code in code base of operations uses static properties
class map @cacherealtor: (realtor) -> realtor.realtor_id = parseint(realtor.realtor_id) # here static property idtorealtormap defined map.idtorealtormap[parseint(realtor.realtor_id)] = new realtor() @init: -> @idtolistingmap = [] @idtorealtormap = []
from can tell these init functions beingness called same way, when page loads init called. both classes static classes, there never instance of either of them beingness created. have thought issue?
the init
function setting instance variable, toggleunreadconversations
function trying reference though property of class.
you should utilize @
refer instance variable init
sets:
class messages @toggleunreadconversations: -> # reference instance variable @viewonlyunread = !@viewonlyunread @init: -> @viewonlyunread = false
javascript coffeescript
Comments
Post a Comment