Structuring clean Javascript

Status
You're currently viewing only KallDrexx's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

KallDrexx

Ars Tribunus Militum
2,040
[url=http:/civis/viewtopic.php?p=25456553#p25456553:34j7hwpc said:
tinyMan[/url]":34j7hwpc]
[url=http:/civis/viewtopic.php?p=25455253#p25455253:34j7hwpc said:
KallDrexx[/url]":34j7hwpc]2nd to last time I tried to write modular javascript I got burned by scoping.

Last time I tried to remedy that by having the "public" function call a nested function using javascript's .call(module) to make sure things were scoped correctly. Not sure that's a good practice though but at least it made my life just a tiny bit less frustrating.

I'm not too sure where you would require the use of .call() with a well constructed set of javascript modules? Was this dealing with event callbacks (onClick handlers?) or in some other context? Have an example?

Yes. I got burned because event handlers were calling module "public" functions and thus scope was becoming unpredictable.
 
Status
You're currently viewing only KallDrexx's posts. Click here to go back to viewing the entire thread.
Not open for further replies.