Question

I find myself having a lot of code which is the same in many js responses such as adjusting heights, and some coloration on the same class, etc.

Is there a way to put all of that duplication in a function and just call that function on each js response? If so, how?

Was it helpful?

Solution

in coffeescript, you can create a global function using

@adjustHeights = (arg1, arg2) ->
  ... code here

then just call this inside the js templates

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top