0

I've been trying some things with ember and my latest test was to update a list based on external event. I have been given some other solutions but the one I came up with (which does not work - for reasons unknown to me) is:

jsBin

If anyone could tell me why this is not working It would be great.

Thanks, Jason

Jason
  • 4,034
  • 4
  • 40
  • 62

1 Answers1

1

You have a scoping issue, fixed at link:

http://jsbin.com/izunik/1/edit

You were referring to "this" inside of set interval which is not the same as "this" in the view.

Cory Loken
  • 1,395
  • 8
  • 8
  • Ah, stupid mistake, not used to javascript. Thanks. By The way, why should I use "didInsertElement" instea of "init"? – Jason Jul 23 '13 at 20:55
  • You want to insure the view is in the DOM before adding children. Although I don't think you would get an error in this simple example I try to avoid init when possible. – Cory Loken Jul 23 '13 at 20:59
  • Sounds good, but are there never situations when its rerenderd or something? (I can solve this with a bool - but still) – Jason Jul 23 '13 at 21:08
  • 1
    A view goes through several states depending on if bound content is changing or other factors. In your case you are changing the bound content and not the view directly so there shouldn't be an error. – Cory Loken Jul 23 '13 at 21:11