Wiring together an Ember application: models, controllers, views, "oh my!"


#1

I’m working on my first Ember application, and I’m having a hard time getting things to work the way I think they should. I feel like, while there’s a wealth of resources out there, there’s also a lack of explanation and intermediate-level examples. Here are some of my challenges:

When looking at models, I’m inclined to try to extensively model all the entities in the application. However, I’m not sure when Ember will try to resolve them, and I’m concerned that it may try to load all the data, spidering down through all the relationships onload. How do I know when/how to control this behavior?

I have a page that’s listing a collection of items which in turn have two collections of sub-objects. I finally got it to sort the sub-collections by using a #while and specifying the array controller. However, I’d like to conditionally alter the display for the first and last items. Unfortunately, that property isn’t on the individual item; it can only be know when used in the context of the collection. I assume this is where I should rely on the controller to decorate the items, but I don’t know how. Or, maybe I’m looking for a Component/View/Template to handle this?


#2

Hi I am an Ember starter too. I think you learn Ember faster by starting with http://www.ember-cli.com/

My example : http://exmer.com/bloggrcouch/

Source: https://github.com/broerse/ember-cli-blog


#3

Thanks; yes, I’m running ember-cli v0.44. It is a nice way to rapidly get setup with a skeleton that looks like it could scale to much larger applications. The one drawback for beginners is there is soo many examples that use the “traditional” one-page style. You have to learn how to cross-walk the examples into the cli structure.


#4

I don’t think ember-cli is the best way to start.

It solve for you some issues about structure and testing, which isn’t anything you can just do yourself at least for the first time.

But, on the other hand, you have to be a little familiar with AMD modules and Brocoli in order to do anything that is a bit outside the ember-cli commands list.

I think the best way to start is to use plain Ember.js and the assets pipeline your are used to (I know assets pipeline is a Rails concept, but I guess python and all the others have the same concept with another name).


#5

I jumped in at the deep end and while I am struggling - it isn’t ember-cli I am struggling with… just my 1p


#6

Maybe is just because I didn’t know enough AMD and brocoli :smile:

I find myself spending more time with it when dealing with integration of external libraries than with Ember itself. It could los be because it was my second Ember app, but I supposed Ember-cli introduce some noise in the first (hard) steps in learning Ember


#7

I can see where you’re coming from with that.

I decided to reverse engineer discourse as my 1st dive into ember… The issue here is that they do some things differently and there’s more layers of “magic” to have to understand - I am ignoring the Ruby side of discourse so some of it is guess work!

I find I get stuff, understand how it all hangs together then I go and try something simple myself and it won’t work!! For instance: Help me figure this UI out!

I hacked it in the end - gave up trying to do it properly and just did it all in one template…


#8

So, I’m feeling a little like my post got hijacked. Does anyone have suggestions on how I can best handle models and collections and such?


#9

Indeed… Can you provide a little example of your problem? Or maybe a jsbin?