ember.js: how do nested resources correspond to templates? - ember.js

given this fiddle ( I couldn't make it work, i'm sorry and very frustrated): i don't understand why, when i ask for a book detail, ember is asking not asking my books/book, but my book template. Is that a feature or i'm doing anything wrong?
And, in addition, when i structure my files tree correctly, asking for book detail gives:
-at 1st try: OUTPU: OUTER
-at 2nd try: OUTPUT: Uncaught You can't call renderToBufferIfNeeded on a destroyed view
and i really can't understand why
thank you

First, of all, here is a working version of your fiddle with latest ember.js and ember-data: http://jsfiddle.net/va9gc/
The reason why ember is looking for book template instead of books/book is because you define book as a resource, not as a route. This is explained here: http://emberjs.com/guides/routing/defining-your-routes/#toc_nested-resources

Related

Inflection usage for fetching model in EmberJS

I am confused at how EmberJS uses inflection to fetch data from local database.
Given that I have a model called Post, I have seen instances of:
this.store.find('post', 1); //This one makese sense to me. Find a record of post with ID 1
I am more confused at when the tutorial starts adding/omitting 's'.
What are the differences between:
this.store.find('post');
this.store.find('posts');
this.store.all('post'); //This one also makes sense. Find all records of post.
The one that specifically confuses me is this.store.find('posts'); when I only have Post model, because it will actually throw an error telling me that No model was found: posts. Nonetheless, I still see it in the tutorial and getting started. Is this just a typo in the tutorial? This is the toturial that I am referring to:
http://emberjs.com/guides/routing/defining-your-routes/
and go to Dynamic Routes section.
Turning my previous comments into an answer in case someone else stumbles upon this before a fix is live.
I feel this has been wrongly downvoted. It is actually a mistake with the guides, as the singular form should be used throughout. The OP's confusion was entirely warranted.
The PR submitted to correct this issue has already been merged.

The story with Index Controllers, Views, Templates?

I've created the following route in Ember:
this.resource('password_reset', { path: '/password_reset' }, function() {
this.route("request");
this.route("claim");
});
The Ember debugger -- which I LOVE btw -- shows me this results in the following:
I have created two templates so far:
/templates/password_reset.hbs
/templates/password_reset/index.hbs
When I go to the URL http://my.server.com/#/password_reset I would expect that -- based on what the debugger's telling me -- that the 2nd template listed (aka, password_reset/index) above is used but in fact it uses the frist one. What doing? Anyone care to shed some light on this mystery?
Ok, I think it can be chalked up to a newbie question. The relationship between these two controllers/views/templates becomes far more clear when I put an {{outlet}} into the /password_reset template. Then I can see that the password_reset/index shows up as the outlet. The index, in effect, becomes the default outlet when a sub-route is not defined. Pretty basic but somehow I didn't get it until I bumped into a wall or two.

What is mean 's' in end of names of controllers and views of Joomla 2.5

I studding to developing component for Joomla 2.5 by this totorial:
http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Developing_a_Basic_Component
Now, there is several cases such as:
HelloWorldControllerHelloWorld
HelloWorldControllerHelloWorlds
in files:
controllers/helloworld.php
controllers/helloworlds.php
or:
HelloWorldControllerHelloWorld
HelloWorldControllerHelloWorlds
in files:
helloworld/view.html.php
helloworlds/view.html.php
My question is:
What the difference between those cases when there is 's' in end and cases when you don't have 's' in the end?
And second thing.
This totorial is very good, but it is good as totorial. Is some one have some site whith deep documentation of all these concepts (exept Joomla API)?
Thank you for ahead.
The "s" at the end of the class declaration denotes the plural. I personally think that this example with HelloWorlds (although correct) is rather confusing for newcomers.
HelloWorld (controller, model and view) (singular) will usually lead to a view where you view or edit a single record.
HelloWorlds will lead to a view where you can view multiple records and perform some operations on them.
On the other hand, I don't think there are a lot of good tutorials, expect that you can look at components included in Joomla (as com_contacts, com_banners, etc).
Also check the documentation regarding Joomla! Naming Conventions
Also I would recommend the book Joomla! Programming from Mark Dexter and Louis Landry. They explain in more details how everything fits together.

Real example of Ember.js

Please give me real example of emberjs. This example will help me understand how to write in emberjs.
Description of example:
Please open this link first:
http://jsfiddle.net/kwladyka/KhQvu/2/
(this is prototype to better understand what i am talking about)
And then read:
Emberjs download Groups.owner by JSON from json.php?name=groups-owner&user_id=58 and Groups.member from json.php?name=groups-member&user_id=58. Both in Groups.all.
In object Groups i have all values of arrays what i read from JSON. I want example read something like that: owner[2][name].
Then from CreateGroupsSelect i want read Groups.all and create ListBox with values group_id and names name. And when i change select i want change <p>You select {{name}} with id {{id}}</p> and refresh data in other View emberjs objects.
I will be really gratefull for help. I am trying learn emberjs but i totally block with this example.
Ok, so i have many questions :)
1)
How to bind value form input select to attribute in controller
var val = $('select option:selected').val();
Where can i find list of possible ussage like a "select option:selected". Any documentatin for that? Where?
2)
"didInsertElement"
How can i know i should use this? How should i looking in documentation to know that? Why not Ember.Select.Change for that?
3)
Why author use "View", i thought for select i should use class "select"?
4)
Seriously this is my first language when i fill all is so random and i dont have any idea how to know what i can write and where. I fill really stupid with that. Any hint how to understand that?
5)
Ok so step by step...
First of all i want read JSON and prepare data to use.
Organizer.Groups = Ember.Object.extend({
owner: [],
member: [],
all: function(){
var owner = this.get('owner');
var member = this.get('member');
return owner.concat(member);
}.property('owner', 'member'),
});
a) "Object" is good choice for that?
b) I want fill "owner" by array from "json.php?name=groups-owner&user_id=58". How to do that? Did i define "owner" corretly or i should write "ArrayController" or something else for that? Mayby just "Array" or "ArrayProxy"? I am filling so confuse now.
c) How should i initiate load data from JSON? I want do this only one time on the beginning.
PS Sorry if you fill my questions are so stupid but i really dont know answers and i dont hide this :)
Here is an example of how to work with select menu in Ember js
select dropdown with ember
Here is an example of working with routes and outlet helper
Right way to do navigation with Ember
If you use routing make sure you have ember latest, routing is still not released.
Router / StateManager - can't make it work
When using latest emberjs refer to documentation in source code, the documentation in ember site will be for present stable release.
https://github.com/emberjs/ember.js
The links to routing is provided from your fidle title "Router with dynamic routes"
It will be hard to solve your complete problem, give it a try starting with the routing example from above, when you are stuck ask more specific questions, we'll be happy to help.
EDIT : Some of the links are already outdated.

Ember.Controller doesn't exist?

I'm just getting started with Ember. I'm a little confused on some things, as the guides on the main site seem to indicate different ways of working.
In the main docs (http://emberjs.com/documentation/), it indicates that a controller should just extend an ordinary Ember object like this:
Ember.Object.extend();
Which works fine for me.
Then in the guide to using Routing (http://emberjs.com/guides/outlets/) it suggests that there is a Controller object type that you can extend:
Ember.Controller.extend();
This doesn't work for me, and if I simply try to console.log Ember.Controller, its undefined.
I'm using Ember version 0.9.8.1.
Should I worry about this, or should I just carry on with extending Objects as my controllers?
0.9.8.1 is aging, and unfortunately even the guides on the site are ahead of it -- use latest (at https://github.com/emberjs/ember.js/downloads) to keep up with the most current best practices.
Update: 1.0-pre is out (emberjs.com), so that is the best to use. The docs / guides have been brought up to date.
I think #pauldechov means the specific "latest" build which you can find here: https://github.com/emberjs/ember.js/downloads
But also keep in mind that the documentation and "latest" are not always in sync.