0

I found this, and I am trying this:

  for _notice in ['created', 'edited']
    ((notice) ->
      Template.test[notice] = ->
        console.log notice
        Session.get notice
    )(_notice)

But in console I am getting created twice, also:

> Template.test.edited
> function () {
      console.log(notice);
      return Session.get(notice);
    } 

I suppose I want to see edited in function, how could I do that? or how can I define these functions using the for loop?

4
  • 1
    (1) The structure works fine, what are you doing differently than jsfiddle.net/ambiguous/L9jLN ? (2) Normally you'd use a do loop for this rather than your own SIF: jsfiddle.net/ambiguous/gsPc8 Commented Jun 12, 2014 at 20:21
  • I forgot to answer the comment, as far as I see I am not doing anything different. Thanks for the do notation, what is SIF? Commented Jun 16, 2014 at 2:44
  • SIF == "self invoking function", i.e. (function(x) { .. })(x) in JavaScript or ((x) -> ...)(x) in CoffeeScript. Commented Jun 16, 2014 at 4:12
  • Can you reproduce the behavior at jsfiddle.net, jsbin.com, or even the "TRY COFFEESCRIPT" tab at coffeescript.org? Commented Jun 16, 2014 at 4:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.