Closed adamtarmstrong closed 8 years ago
Where is your config located? Alloy.js?
no. in the same controller file associated with the view. me_root.js (logic + reste config) me_root.xml view
Ok that's your problem. You can't define the collections in the same controller / view. It's telling you it doesn't exist because the binding takes place before the JS code is run.
Move the JS code above to index.js or alloy.js so it's executed before the target controller is opened.
You only need one reste config so alloy.js is the best place.
oh. so its more of a "timing" issue. Sorry, I had no idea. I just moved to alloy.js and it worked. Thank you, thank you, thank you so much!
Kind of -- the way Alloy binding works anyway is to do the binding BEFORE the JS is run -- so you'd define your models / collections as per normal Alloy subfolders etc and then you can bind this to views -- the binding occurs before the JS runs.
So with RESTe, you need to define the config in the alloy.js or index.js (as long as index.js isn't binding anything) and then you're fine.
It's also why, if you want to say do binding of sub collections e.g. a "comments" array within a model, you have to do this BEFORE you open the comments binding view.
So if I have a collection of posts and then the user clicks one and I want to show the post and comments, I'd generate an on-the-fly collection on the click, in the post list controller BEFORE I open the view/controller that's binding the comments.
So yes, it's timing but it's all about how binding in Alloy works.
I have read through your doc over and over for, literally, weeks and I cannot figure out what I'm doing wrong.
Error: "Can't find variable: retailers";
JS File
XML