Menu
  • HOME
  • TAGS

How is Sorting achieved in an Ember model without using Array Controller?

ember.js,ember-data,ember-cli

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....

How to add a custom row for adding data to ember-table?

ember-cli,ember-table

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...

embjerjs select from dynamic data

javascript,ember.js,ember-cli

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 =...

NPM repo missing file

ember.js,npm,ember-cli

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...

Ember Data “modelFor” error when serializing models

ember.js,ember-data,ember-cli

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.

Exclude folders from builds in Brocfile

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...

Ember-cli: New project without Handlebars

javascript,ember.js,ember-cli

Since Version 1.10, ember is dependent on HTMLBars. You can read more here

Ember - Nothing handled the action occurs

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 =...

Ember CLI generated unit test is failing on it exists

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']}); ...

Ember-cli resolver

javascript,ember.js,ember-cli

import Settings from '<app-name>/settings';.

Optimizing emberjs filter search

javascript,ember.js,ember-cli

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:...

Load and unload multiple components in a sidebar using Ember

ember.js,ember-cli

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...

giving an input a dynamic value emeberjs

javascript,ember.js,ember-cli

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); } ...

Can ember-cli watch and build automatically without running the server?

ember.js,ember-cli

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...

Ember Data One to One Relationship Record Creation Fails

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,...

Accessing indexed item from array in HTMLBars

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}} ...

Ember JS - Handlebars template - @index being undefined inside #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....

watchman not found on phusion/baseimage Docker image with ember-cli

docker,ember-cli,watchman

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-2.0 angle-bracket component not working with [email protected]

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...

Ember-cli how to add FileSaverjs and Blobjs

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...

Ember CLI Install Addon

ember-cli

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...

How can I include html with ember-cli only for a specific environment?

ember.js,ember-cli

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(); } ...

Emberjs toggle effect of dynamic data

javascript,ember.js,ember-cli

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...

Ember.js: Loading related models directly

ember.js,ember-data,ember-cli

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...

Ember CLI with Multiple Proxies

proxy,ember-cli

var proxyPath = 'myapp/api/v1'; You're missing a / in the beginning of the string ;)...

Ember library causing “Binding Style Attributes” deprecation warning

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'", ...

How to fix 'Microsoft' is not defined in Ember CLI Bing Map?

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....

How to create route in right way?

ember.js,ember-cli

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...

How can I declare globals for jshint to ignore in ember-cli?

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....

Ember: Access ember data 'store' object from utility class

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...

ember-cli migration: global app module import

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.

configuring server and client ports in Ember-Cli

ember.js,ember-data,ember-cli

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' }...

Ember CLI with Pods

ember.js,ember-cli,ember-pods

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...

ember-cli scss lint addon not performing task

ember.js,ember-cli,broccolijs

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...

Model object not preserved when using hash for model in ember route

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...

Cannot read property 'match' of undefined at Ember.DefaultResolver.extend.podBasedComponentsInSubdir

ember.js,ember-data,ember-cli

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...

Using ember-data with custom serializer

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...

How to set different Compass configuration options for environments in Broccoli?

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')...

Display Ember library versions in browser console on app load

ember.js,ember-cli

// 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...

Component exposed in ember addon is not recognised in ember app

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....

How to create unit tests for Ember.js adapter/serializers?

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...

Ember CLI path based on server response

ember.js,ember-data,ember-cli

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...

Rendering dynamically generated {{link-to}} links in an Ember.js Handlebar template expression

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...

Problems installing ember-cli using npm on c9.io IDE

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...

how to add event for drop-down component to change subdomain by selected item

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...

One passing Ember integration test breaks the next one: bad teardown block?

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....

Ember-cli 0.2.5 livereload keeps reloading in every change

ember-cli

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 $...

Override Ember application.hbs template

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 ...

ember build Parse error on line 1: {{#each messages as |message|}}

ember.js,ember-cli

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...

How can I return a well formatted 201 with Express?

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 ""....

Polymer 1.0 in Ember-cli, wrong appearance

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...

Rails, ember-cli-rails gem

ruby-on-rails-4,ember-cli

I just fixed this problem by adding some tasks to my deploy.rb file.

Where do 3rd party JS libraries go?

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 passing a model to transitionToRoute

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...

How can I fix tests in Ember testem with errors such as 'could not load', 'failed', 'could not find module' or 'died'?

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...

In Ember how can I create a component by name programmatically

ember.js,ember-cli

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...

Ember.js: Which controller is in charge?

ember.js,ember-cli

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}} ...

with ember cli, how to specify different layout for a component within POD structure

ember.js,ember-cli

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...

Ember-cli ProxyPass

ember.js,ember-cli,proxypass

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....

Multiple routers for an Ember app

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:...

How to set the i18n.locale from within an initializer

ember.js,ember-cli,ember-i18n

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...

Ember CLI Rails: Creating user model

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',...

EmbeddedRecordsMixin not working as expected, what am I missing?

ember.js,ember-data,ember-cli

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...

How to get current route path in helper in Ember?

javascript,ember.js,ember-cli

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...

Ember error on refresh

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...

EmberJS: Render default template

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', {...

How to not always compile all assets on autoload in ember.js

ember.js,ember-cli,broccolijs

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...

Ember Simple Auth: how to keep data in a step by step process after redirection to login route

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....

changing the value of a model property emberjs

javascript,ember.js,ember-cli

Have you tried using Ember.set() as the message said? Ember.set(m, 'showDetails', true); http://emberjs.com/api/classes/Ember.html#method_set...

Ember-cli non ember function

ember-cli

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. ...

How to get the clicked element on Ember Component

ember.js,ember-cli

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...

How to dynamically apply classes to objects in ember-cli?

ember.js,ember-cli

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')); }),...

Ember-CLI Route model data not affecting template

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}} ...

Security problems in upgrading ember application

ember.js,ember-data,ember-cli,content-security-policy

I believe you need to add multiple hosts, one for port: 8000 and port: 4200

update dom after persistence emberjs

javascript,ember.js,ember-cli

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...

ember nested route not loading

ember.js,ember-data,ember-cli

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...

Accessing an Ember CLI app's config from within an addon

ember-cli

Found the answer here. Basically, you can look it up through the container like so: this.container.lookupFactory('config:environment').modulePrefix; ...

Ember Validations stopped working after updating to [email protected]

ember.js,ember-cli

Turns out that ember-addons.bs_for_ember was causing this issue. I removed this dependency form my Brocfile.js and then everything worked.

Ember Routing Model Observing Updates in Handlebars Template

ember.js,ember-data,ember-cli

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. ...

How to run action in Ember Controller afterRender

ember.js,ember-data,ember-cli

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"); } } }); ...

Ember blueprint that injects environment config?

node.js,ember.js,ember-cli

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...

Error message about #each looping over a non array when it is already an array

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 1.12 deprecation warning about The `initializer` API

ember.js,ember-cli

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 ...

Ember belongsTo relationship passing as nil to server on saving

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.'}); }); } ...

Activating Feature Flags with Ember CLI

ember.js,ember-cli

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.

How does one access model data in a router/controller?

ember.js,ember-cli

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 CLI: Build for staging

ember.js,ember-cli

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...

Custom API calls with Ember Data

ember.js,ember-data,ember-cli

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...

simple way to configure or modify indentation in default blueprints for `ember generate`

ember-cli

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....

When creating a new data object in Ember that relies on another object how do you pass it along?

ember.js,ember-cli

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',...

How to accept model collection metadata, such as count in ember?

ember-data,ember-cli

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...

Fetching API data from Ember Controller

ember.js,ember-data,ember-cli

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:...