You just need to include a SortableMixin to either controller or component and then specify the sortAscending and sortProperties property. Em.Controller.extend(Em.SortableMixin, { sortAscending: true, sortProperties: ['val'] }); Here is a working demo....
I'd suggest extending Ember Table to override footerContent: import Ember from 'ember'; import TableComponent from 'ember-table/components/ember-table'; MyTable = TableComponent.extend({ footerContent: ... }); You'd then override Ember.Table.Row with a custom row, and put that into footerContent. You could define an extra action on that row which grabs the row's data and...
Yeah you are definitely trying to set the content property of the select with a promise. A computed property doesn't block on return of a promise like you are hoping it will here. The workaround: groups: null, setGroups: function(){ var self = this; var model = this.get('model'); var adapter =...
I confirmed that your repo looks fine npm install ui-responsive-toolbelt does not download the index file So the problem is that npm publish is not working properly. There is a bug filled for that. https://github.com/npm/npm/issues/5082 What you can do is publish again your addon using a recent npm version...
I have managed to fix the problem by re-installing ember-cli and ember-data. I assume something went awry during the upgrade process recently when I went from version 1.12.0 to 1.13.0 and ember-data 1.0.0-beta.17.0 to 1.0.0-beta.19.1.
javascript,ember.js,ember-cli,broccolijs
Ah, so after actually thinking about this clearly, everything is actually working exactly as expected in my previous example. I clearly wasn't paying enough attention. app.toTree() is far to late to perform this operation, as everything has already been built and concated. Luckily, ember-cli does enable addons to modify the...
Since Version 1.10, ember is dependent on HTMLBars. You can read more here
ember.js,ember-data,handlebars.js,ember-cli,handlebars
When you trigger the action refresh, ember will look for the action in the controller. Since you have not specified a controller for the view, the controller for the application template will be used which is App.ApplicationController. You can use the following code and your action will trigger. App.ApplicationController =...
javascript,unit-testing,ember.js,ember-cli,ember-qunit
You need to inform the test of the controller dependencies. In order to do this, change your moduleFor method to the following: moduleFor('controller:order', { needs: ['controller:orders']}); ...
You could change your controller so you always return all records when no search term is entered, and only filter when searchKeyword has text. Then in your template you can remove the if statement and the 2nd each. Something similar to the following: js: export default Ember.ArrayController.extend({ searchKeyword: null, searchResults:...
Assuming you are running Ember 1.11+, you can use the new component helper Basically, you could do something along the lines of: templates/main_view.hbs <div class="sidebar"> {{#each componentNames as |componentName|}} {{component componentName}} {{/each}} </div> and your buttons to create said components in: templates/main_view.hbs <button {{action "addAddress"}}>New address</button> and the actions themselves...
value is passed in, so you need to define in your function definition. function(value){ console.log('action worked'); // note this will just be the id, you may want to query your collection // and use the object instead of the id... this.set('selectedProduct', value); } ...
If I understand correctly you are wanting the ember build command to watch for changes in the file tree and rebuild on a change? They implemented ember build --watch a while back which will trigger when a file changes. Tested just now and it worked on 0.2.7. Not sure what...
json,ember.js,ember-data,ember-cli
You can create a custom serializer, if you can't modify your json response and manage to arrange data in other way App.MODELNAMESerializer = DS.ActiveModelSerializer.extend({ extract: function(store, type, payload, id, requestType){ var shipments = []; //CREATE A NEW PAYLOAD THAT EMBER CAN READ var _payload = { }; return this._super(store, type,...
javascript,ember.js,ember-cli,htmlbars
To access element at specific index of array in template, you should use syntax {{array.[index]}} According to your api response, this should probably work: {{#each m in model}} <tr> <td> <a href="{{m.links.[0].uri}}">{{m.name}}</a> </td> </tr> {{/each}} ...
javascript,templates,ember.js,ember-cli,handlebars
Since ember 1.11.0 index support has been added to the each helper. You can use it like {{#each model as |book index|}} {{index}} <li>{{#link-to "books.about" index}} {{book.name}} {{/link-to}}</li> {{/each}} Here is a working demo....
It looks like the current build of watchman is failing, I tried the latest stable one and it seems to work with your steps above. Just grab v3.1 and it should work: RUN git clone https://github.com/facebook/watchman.git \ && cd watchman \ && git checkout v3.1 \ && ./autogen.sh \ &&...
ember.js,ember-cli,htmlbars,ember-components
At this point in time, that feature is still behind a feature flag. So the appropriate flag must be enabled. Feature flags are enabled in config/environment.js and in your case, it should likely look somewhat like: ... EmberENV: { FEATURES: { 'ember-htmlbars-attribute-syntax': true, 'ember-htmlbars-inline-if-helper': true, 'ember-htmlbars-component-generation': true } } example...
javascript,ember.js,bower,ember-cli
Bower assets have to be imported in Brocfile.js, see http://www.ember-cli.com/#managing-dependencies In my project, filesaver is located at bower_components/FileSaver.js/FileSaver.js, so I have the following line in my Brocfile.js: app.import('bower_components/FileSaver.js/FileSaver.js'); This makes it available as a global on window.saveAs, no need to use an import statement in the file you use it...
Essentially, yes, ember install <addon-name> does execute npm install --save-dev <addon-name>. However, it'll also perform any necessary additional setup required by the "blueprint" or add-on hooks (adding bower dependencies, editing a .jshintrc file, or many other tasks). This might not be applicable to some add-ons, but it is a good...
You can still check your config file from any file in your project: import config from '../path/to/config/environment'; if(config.environment === "development") { someScript.init(); } ...
Add a property to each item in the model named something like isDetailsShown. You can modify you action by passing the item into the method. <p {{ action 'displayDetails' item}}>{{m.name}}</p> In the action, just toggle the property of the passed in item. displayDetails: function(item){ item.toggleProperty('isDetailsShown'); } Finally modify the if...
How does Ember know to automatically fetch relationships? ember-data allows you to define relationships (currently only belongsTo and hasMany) with async option set to true or false. Based on this option, after fetching the model from the API (via find method), ember-data will expect relationships object either directly in the...
var proxyPath = 'myapp/api/v1'; You're missing a / in the beginning of the string ;)...
javascript,ember.js,ember-cli,filepicker
This is a CSP issue. You can disable this warning by editing your config/environment.js file: Find: ENV.contentSecurityPolicy = { And edit the 'style-src' attribute to include 'unsafe-inline' 'style-src': "'self' 'unsafe-inline'", ...
ember.js,ember-cli,bing-maps-api
You need to specify the global variables in .jshintrc file. Add Microsoft to the predef array in the file and your jshint errors should go away....
Seems like you are talking about ember query params. App.CategoriesCategory = Ember.Controller.extend({ queryParams: ['filter'], filter: '' /* default value */ }); and to transit user to this route with filter parameter use following helper {{#link-to 'categories.category' url (query-params filter="top")}}Show top{{/link-to}} if you do not want to use the parameter then...
ember.js,ember-cli,jshint,sinon
You're editing the wrong .jshintrc file. The one located in the root directory is for the app. There is an additional .jshintrc file for the tests. Edit the one located at /tests/.jshintrc....
javascript,ember.js,ember-data,ember-cli
Make your utility into a "service", into which you can inject the store. Actually, it sounds like your utility should be a service anyway, even if it doesn't need the store. By making it a service, for instance, it becomes much easier to stub it out when writing tests. With...
javascript,ember.js,ember-data,ember-cli
Your issue is that the module path contains the .js extension. Change the path to just '../app' and it will work just fine.
You just want ember to use a different port for your API depending on the environment? It sounds like you need have your application adapter grab a value from your environment file //environment.js var ENV = { ... apiHost: 'https://path-to-production-api.com', ... } if (environment === 'development') { ENV.apiHost: 'http://localhost:8080' }...
As stated in my comment, remove podModulePrefix from your environment file and throw your pods in the root of the app folder. I've never been able to get podModulePrefix to work, and I believe the momentum is against putting your pods in a separate folder anyway. Since pods are destined...
I was unable to use the tree passed in from toTree so I instead settled for grabbing the styles tree from the application app.trees.style and that seems to have done the trick. I feel this is more a limitation of broccoli-scsslint than ember-cli. If anybody can suggest an improvement, you...
javascript,ember.js,ember-data,ember-cli
You're sending the model color when you're linking here: {{#link-to 'color' color}}{{color.name}}{{/link-to}} Because of that, the model hooks aren't run. If you change that to color.id, it'll work. It's mentioned here. In the above example, the model hook for PhotoRoute will run with params.photo_id = 5. The model hook for...
Okay I figured out what was being done wrong... I forgot to check if the data being returned by the server abides to the convention/protocol required to use ember data. The JSON returned by the server looks like this. [ { "_id":"55405a5102b4ed623c225e87", "alias":"mikeTest", "__v":0, "scans":[], "createdAt":"2015-04-29T04:13:05.223Z" } ] It should...
javascript,ember.js,ember-data,ember-cli
Just some tips from my side using Ember Data. I believe that you either have to be able the adapt api or write a deserializer: 1. Root Key "data" Ember expects the root key to be the name of the model (e.g. "company"). You can handle that easily by creating...
ember.js,ember-cli,compass,broccolijs
With EmberApp.env() you can get the current environment. For instance: Running ember build returns "development" and ember build -prod returns "production". So in the worst scenario, where an addon doesn't provider options by environment, you are able to do this: var env = EmberApp.env(); var compassOptions; if (env === 'development')...
// app/app.js Ember.LOG_VERSION = true; LOG_VERSION determines whether Ember logs info about version of used libraries. True by default http://emberjs.com/api/#property_LOG_VERSION...
ember.js,ember-cli,ember-addon,ember-components
Running ember install ember-cli-test-recorder solved this for me. For some reason just running npm install ember-cli-test-recorder wasn't enough....
unit-testing,ember.js,ember-cli
If you want to create unit tests for your adapters and serializers, you should look at how ember data tests those themself. Basically, you can look at the test for the RESTSerializer etc. and use their technique. Example serializer: https://github.com/emberjs/data/tree/master/packages/ember-data/tests/integration/serializers The code that ember data uses to achieve this: https://github.com/emberjs/data/blob/master/tests/ember-configuration.js#L49...
To be honest I don't understand why do you use this.route('options', { path : ':slug' });. You just created the only route for all possible options (in fact, for all urls of form /anything), but that's not what you want. I think your solution is this.transitionToRoute(url_string) which is available in...
javascript,ember.js,ember-cli,handlebars
Well, you could do it with an computed property The caption: This is my #hashtag caption In controller: computedCaption: function () { var words = caption.split(" "); return words.map(function (e) { var isHashtag = e.charAt(0) === "#"; return {isHashtag: isHashtag, text: e}; }); }.property("computedCaption") Template: {{#each computedCaption as |cap|}} {{#if...
node.js,phantomjs,ember-cli,cloud9-ide
There's no need to use sudo while installing modules globally on Cloud9. I just tried the following command: npm install -g ember-cli which completes without any problems. $ which ember /home/ubuntu/.nvm/v0.10.35/bin/ember Also, yeah, how come your workspace is using node v0.10.28, did you install node yourself? Your paths should be...
ember.js,express,ember-data,subdomain,ember-cli
You can add an action to your component and when you select an option, you can send it up using the sendAction method. Your component will look like the below code. In that I have added an extra property action="countrySelected" where countrySelected is an action defined in either your controller...
ember.js,ember-cli,ember-qunit
Your setup and teardown looks fine. They are commonly used and are properly defined. However, there is (still) open issue on ember-qunit about not tearing down the app properly - take a look here to see the progress. As you said, it does not happen in Ember 1.13....
I had this problem with watchman 3.1.0 (which is the version that Homebrew installs) so I upgraded to 3.1.1 and it seems to have been resolved. You'll need to install it from source, but it's easy: $ brew uninstall watchman Then just $ git clone https://github.com/facebook/watchman.git $ cd watchman $...
javascript,ember.js,handlebars.js,ember-cli,handlebars
To get rid of {{link-to 'main.posts'}}. You can add {resetNamespace:true} to a given route. this.route('main', {path:'/'}, () => { this.route('posts', {resetNamespace:true}); }); {{link-to 'posts'}} will navigate to your posts route ...
I think you might be using old version of HTMLBars and/or Ember CLI. You should upgrade to Ember CLI 0.2.7 from ^0.1.11(that's weird you're using ^ here, because upgrading from each version of Ember CLI requires some steps to take) and ember-cli-htmlbars to 0.7.6. Here's the valid package.json file for...
jquery,ember.js,express,ember-cli
The problem is it's trying to parseJSON on a blank response. It's effectively doing jQuery.parseJSON('') - which does produce an error if you try an run it. To resolve it you could return any string that can be parsed as JSON - e.g. the string null or empty quotes ""....
javascript,ember.js,polymer,frontend,ember-cli
i have been trying to use polymer 1.0 with ember for the last month, turns out some polymer elements that use as insertion points will not work with ember. I have spoken with a polymer core member and he said they are curerntly working in some interop to get things...
I just fixed this problem by adding some tasks to my deploy.rb file.
ember.js,ember-cli,ember-cli-pods
Yes there is a convention. Use bower if a package exists. If it doesn't, download the repo into the vendor folder. Import the file in your Brocfile.js app.import('vendor/path_to/main_js_file.js'); ...
ember.js,ember-cli,ember-router,ember-controllers
You are dealing with a classic problem occurring in many Ember applications which is how to handle "new"/"create" situations. You cannot define a route such as this.route('addcontact', { path: /addcontact/:thing_id } because the the new contact doesn't have an id, and won't until it is persisted to the server, at...
ember-cli,testem,karma-coverage
I ran into "No tests were run,..." problem recently after a node upgrade. I fixed it with a: npm install -g phantomjs This provides some additional options as well: https://github.com/ember-cli/ember-cli/issues/3969...
You could use component helper with dynamic component-name in template. App.FooComponent = Ember.Component.extend({..}); App.BarComponent = Ember.Component.extend({..}); var dynamicName = 'foo-component'; // template.hbs <div id="some-area"> {{component dynamicName}} </div> See component helper guide here: http://emberjs.com/api/classes/Ember.Handlebars.helpers.html#method_component UPDATE: You could use model to provide rendering logic: // model is array of objects or records...
Controllers no longer proxy properties from the model. You need to fully qualify the property you want to access. The model is now the property model on the controller (which is what item is now). Property on the model {{item.model.title}} Property on the controller {{item.fooProp}} ...
So component's and layout don't exactly work out of the box like you are expecting. Lets say we have component called my-component. Ember interprets the template you define at templates/components/my-component as the layout and anything you wrap the component around via block syntax: {{#my-compenent}}{{/my-component}}as the component's template. Look at this...
During development, you should use an http-proxy generator to create a path to your API. ember help generate lists the syntax: http-proxy <local-path> <remote-url> Generates a relative proxy to another server. This generates a proxy that only exists during development (in /server/proxies/), and is not compiled in a production build....
javascript,node.js,ember.js,ember-cli,ember-router
You can define ur routes in seprate files inside a function and export that function like page1.js export default function() { this.route('page1'); } page2.js export default function() { this.route('page2'); } Then import that into your router.js file. import page1Routes from 'page1'; import page2Routes from 'page2'; var Router = Ember.Router.extend({ location:...
You could get i18n as service:i18n and use instance-initializer to set i18n.locale. //app/instance-initializers/user-locale.js export function initialize(instance) { var i18n = instance.container.lookup('service:i18n'); i18n.set('locale', 'de'); } export default { name: 'user-locale', after: "ember-i18n", initialize: initialize } InstanceInitializers guides: http://emberjs.com/deprecations/v1.x/#toc_access-to-instances-in-initializers http://emberjs.com/blog/2015/05/13/ember-1-12-released.html#toc_instance-initializers...
javascript,ruby-on-rails-4,ember.js,devise,ember-cli
After realizing what 422 response actually meant and what I needed to pass back I concluded on sending the json errors back in user_controller.rb and displaying growls for each one. JS Controller Action: actions: { createUser: function() { var user = this.store.createRecord('user', this.get('model')); var self = this; user.save().then(function() { self.get('session').authenticate('simple-auth-authenticator:devise',...
The problem is the fact you're reimplementing extractSingle yourself. You should call this.super if you're doing this.. In extractSingle on the REST Serializer it calls the normalize function - this normalise function is where the EmbeddedRecordsMixin does all it's work. Because you're not calling either this.super or manually calling this.normalize...
Although it's a private API, I've been known to use and abuse the container for when I need it. The application controller has the currently active route as a property called currentPath. import Ember from 'ember'; export default Ember.Handlebars.makeBoundHelper( function(value, options) { var appCtrl = this.container.lookup("controller:application"); return appCtrl.get('currentPath'); }); This...
javascript,ember.js,ember-data,ember-cli
Your problem lays in routes/package.js file. Examine what you are doing in the model hook: model: function(params) { return this.store.find('package', params.package_id); } You are fetching one package from the API. You have not defined setupController, therefore the result from the model hook is automatically set on model property of your...
javascript,templates,ember.js,handlebars.js,ember-cli
Ember Route provides a renderTemplate hook which you can use like this: App.PostsIndexRoute = Em.Route.extend({ renderTemplate: function() { // renders the template for the current route, as per conventions // in your case it will be 'posts/index' this.render(); // renders the named template 'posts/feature' *into* another named template this.render('posts/featured', {...
Not sure on compass but I think its related to this issue over on ember-cli-less with sourcemaps https://github.com/gdub22/ember-cli-less/issues/10 https://github.com/ef4/broccoli-sourcemap-concat/pull/3 The issues have been closed but on a fresh ember new they are still present...
javascript,ember.js,ember-cli,ember-simple-auth
I found a workaround. When I enter the process, I create and save a booking object, allowing me to have an id and to save the progress at every steps. If you need more details, just let me know....
Have you tried using Ember.set() as the message said? Ember.set(m, 'showDetails', true); http://emberjs.com/api/classes/Ember.html#method_set...
You can place it in a util script. To create one, type in ember generate util foo Take note that it uses ES6 syntax with the export default and stuff. Once you have the util script you can import it in your controller, route, etc. ...
Ember.EventDispatcher delegates some events to the corresponding Ember.View. Since Ember.Component is a subclass of Ember.View, you can capture click events just exposing a click function: export default Ember.Component.extend({ click: function (event) { console.log(event.target); // displays the clicked element console.log("Hello from component"); } }); Keep in mind that using directly these...
1)As component you can do something like below: in template {{#each category in category_options}} {{category-button category=category selectedCategoies=selectedCategories action="filterCategory"}} {{/each}} component template {{category}} component export default Ember.Component.extend({ tagName: 'button', classNames: 'btn-small', classNameBindings: 'isFiltered:btn-active:btn-inactive', isFiltered: Ember.computed('category', 'selectedCategories', function(){ return this.get('selectedCategories').contains(this.get('category')); }),...
javascript,ember.js,ember-cli,handlebars
The variable should be {{model.title}} You can log out variables from your template with {{log title}} {{log controller.title}} {{log model.title}} This might help you to debug faster. You should then be able to pass data in to our component with something like: {{my-component title=model.title}} ...
ember.js,ember-data,ember-cli,content-security-policy
I believe you need to add multiple hosts, one for port: 8000 and port: 4200
So the problem here is that you are dealing in POJOs and you should be dealing in Ember.Object If you update a POJO, handlebars doesn't recognize this change. If you update an Ember.Object called say object and you are displaying this in a handlebars template as {{object.someProp}}, updating someProp will...
Essentially I wanted that specific template image/index.hbs to have a nested templated image/comments.hbs which used its own model. So when I goto the route image/index it loads index.hbs with comments.hbs nested: To achieve this I changed the comments partial to an outlet: template/image/index.hbs: <div class="container"> {{partial "image/actualimage"}} <div class="row"> {{outlet...
Found the answer here. Basically, you can look it up through the container like so: this.container.lookupFactory('config:environment').modulePrefix; ...
Turns out that ember-addons.bs_for_ember was causing this issue. I removed this dependency form my Brocfile.js and then everything worked.
If you use model = Ember.Object.create({title: 'old Title'}), then you can use model.set('title', 'new Title') to set a new title, that will be updated on the view automatically. Here is a simple example JSBin: http://emberjs.jsbin.com/xuzevizabe/2/edit But it seems that you instead want to use ember-data to handle your models. ...
You could use init: App.Controller = Ember.Controller.extend({ init: function () { this._super(); Ember.run.schedule("afterRender",this,function() { this.send("foo"); }); }, actions: { foo: function() { console.log("foo"); } } }); ...
No there's no existing magic in Ember to my knowledge sorry. When you generate a route, something very similar to what you are talking about happens but the code is rather complex. The ember generate route new_route function has a call to this function function addRouteToRouter(name, options) { var routerPath...
ember.js,ember-cli,ember-addon
This is caused because prototypes are turned off by default for addons. Ember's each helper expects an Ember array. Since prototype extenstions are turned off you will need to manually wrap an array in Em.A operations : Em.A(['search', 'create', 'read', 'update', 'delete']), This blog post from dockyard will be helpful...
Ember Data is most likely causing the issue, I saw it yesterday on one of my apps, you can checkout the stack trace and likely see who the culprit is. https://github.com/emberjs/data/issues/3051 ...
javascript,ruby-on-rails,ruby,ember.js,ember-cli
In createCourse method course.save() runs before user promise becomes resolved, that's why you see user_id: nil. This would work: createCourse: function() { var self = this; var course = this.get('model'); this.store.find('user', this.get('session.content.secure.id')).then(function(user) { course.set('user', user); return course.save(); }).then(function(course) { $.growl.notice({title: 'Course', message: 'Sucessfully created course.'}); }); } ...
Nevermind, just found the answer. I had to be on canary to get access to the code. You can find out how to be canary here.
afterModel will run only once the model has been resolved, and the model is passed as an argument. So, based on my understanding of your app, you can adjust your routes/menu example to: export default Ember.Route.extend({ model: function() { return this.store.find('menu'); }, afterModel: function(model) { Ember.$(document).anystretch(model.get('firstObject.image')); } }); ...
Ember sets a flag depending on whether production ONLY is specified in /ember-cli/lib/broccoli/ember-app.js: var isProduction = this.env === 'production'; and then it uses the settings specific to production. So if you want to have a staging build use a process to modify the environment.js before your run ember build then...
You'll want to override the urlForFindQuery method in your adapter. Looking at the default source here, you can probably come up with something pretty simple: export default DS.RESTAdapter.extend({ urlForFindQuery(query, modelName) { const url = this._buildURL(modelName); return `${url}?first_name||last_name=*${query.search_term}*`; } }); Obviously that's not a fully working example, but hopefully you get...
The ember-cli developers intend to make ember generate commands respect configuration settings specified by an .editorconfig file: https://github.com/ember-cli/ember-cli/issues/3664 Thus, specifying indentation preferences in an .editorconfig will solve this problem....
There are many points to fix: 1) {{controllers.customer}} is Controller Object, {{controllers.customer.name}} it's name property. I think you want {{controllers.customer.model.name}}. 2) "..newOrder.customer = customer.." should be newOrder.set('customer', this.get('controllers.customer.model')); 3) your customer.order.create route model hook shoudn't be empty, since you are using dynamic segment customer_id: //route model: function(params) { return this.find('customer',...
So if you are in control of the API then you can use built-in support for metadata provided by Ember Data (using DS.RESTAdapter). If you return the following structure from your API: { "users": [{ "id": 1, "name": "Bob" }, { "id": 1, "name": "Bob" }], "meta": { "user_count": 5...
First of all, when you execute store.find('modelName'), Ember REST API Adapter expects an array of models in response. Then, promise of store.find resolves with array of objects, and you have to get first object to see if success === true. this.store.find('validemail', {'email':'abc.gmail.com'}).then(function(validEmails){ console.log(validEmails.get('firstObject.success')); // true || false }); API method:...