return '<button onclick=somefunction(somedata)>'
, but I don't see that going a long way: what if I don't have a reference (even within a namespace) in the global scope? Thanks.
So no easy fix for my problem? :D
By the way @jdubray, what are your opinions about Ember? It offers some solutions to some of your problems. For instance, the models on the client don't have to match exactly what you are retrieving from the server. First you have a so-called "adapter" that can modify the data before it comes in or gets out, and then (and most importantly) your client models can have computed properties, e.g. if you have a Person model, and the age is coming from the server, you can define a property that computes on the fly "young" or "old" based on the age attribute.
@jdubray the problem I see is that, if I have a function myAction
, and I want it to be bound to the onclick
, I have to write (as a string) something like onclick="myAction"
. But that will only work if that function is reachable from the global scope, which is something you want to avoid at all costs when developing serious JS applications.
If I pack my whole application within an object that acts as a namespace, for instance MYAPP
, and I expose my function there, I could write onclick="MYAPP.myAction"
, but still it would be better not to do so, and somehow bind the handler in another way.
nap()
doesn't know if it already has set a timer or not, it may set multiple timers i.e. running any other action during the countdown sets another timer. The end result is the same as these multiple timers don't interfere with one another, still, this could become a problem scaling. I don't like having to store a flag (mutate the state) just to indicate that a timer has been set. Do you know of any other solution?