Is there a way to get the class or type of a model? For example if my model was a "todo" and if I wanted to get that information from the record itself like:
todo = this.get('model');
todo.class
OR would it possible to get it from the 'content' of a controller? I think model is just an alias for content but I could be wrong. I figured there has to be a simple way to do this but I can't find anything after much googling. Thanks in advance for the help.
the constructor is probably what you're looking for, it's located on the proto of the object
`todo.constructor`
http://emberjs.jsbin.com/OxIDiVU/871/edit
I got it working with the following:
type = #get('model').get('constructor.typeKey')
Thanks to kingpin2k for the help.
Related
I am trying to add a custom method on one of my CFWheels Model but I am not able to do this. I have been reading the documentation but still not found an answer.
User.cfc
component extends="Component" {
...
function getCustomSearch(){
...
}
...
}
I want to change:
model("users").findAll(...)
To
model("users").getCustomSearch(...)
In order to refactor some function.
Is this possible? In that case, what I am doing wrong?
Thank you for your attention.
Regards.
It will need to be model('user') not users; Wheels looks for the singular variant to match the models/User.cfc file.
I have left my computer and when I came back it was working. Dan Roberts was right, it's necessary to reload.
Thanks to all for the help!
How do I make the buying process very simple without registration:
What I need is here?
catalog/controller/checkout
catalog/language/english/checkout
catalog/model/checkout
catalog/view/theme/default/template/checkout
Or somewhere else?
I have simplified the registration form:
http://i62.tinypic.com/veufqp.jpg
A problem with catalog\model\account\customer.php
http://i59.tinypic.com/11ujfq0.jpg
I understand what went wrong, the model does not receive the necessary variables.
But how to drown out the missing variables?
The right to request in the model or you can somehow do it in the controller?
Location data model takes ?:
- POST
- date
- session
Anyone have any ideas why I'm getting this error:
Uncaught TypeError: Cannot redefine property: __ember1346884664897
when calling:
App.get('router').send('tags')
I'm making the call from one of my views, the router is in the correct state, and as far as I can tell I'm doing everything by the book.
Would really appreciate any ideas...
Created a gist that might help explain things a little better. https://gist.github.com/3647288
App.router.send('something') will look for a function named something in your current state, but you are trying to use route name there. You should have something like showTags in you router and use App.router.send('showTags').
Head to docs http://docs.emberjs.com/#doc=Ember.Router&src=false and look at the part Transitions Between States
I had this problem when I named an action and a state the same way. Perhaps you have the same thing now.
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.
I would like to "current location bar" id Django. Something like on eBay under the "Women clothing" (eBay>Fashion>Women's Clothing), but I don't really know how to do it.
I was wondering if I should use request.get_full_path() or something like that, but it seems very dirty to me.
Thanks in advance,
Adam
What you're looking for is called "breadcrumbs" and you can find a nice snippet here
As said there:
The URL
/users/foo/config/
will get to these breadcrumbs:
Users>>foo>>Config
which is basically the correct way to understand this snippet!
Hope it helps
you're wanting the full breadcrumb trail?
Usually you just use django's url template tag: https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#url and reverse each known url for where you are on the site.