ember.js

Accessing a service's promise from a route

空扰寡人 提交于 2020-01-06 04:00:06
问题 I am struggling to a Service's promised data in a Route. The problem occurs when I am transitioning to the Route at application init; that is, if I load the application, then transition, everything is fine, because the promise is already fulfilled, but if I hit browser reload on that Route, the offending lines won't run. The Service is: // services/lime-core.js import Ember from 'ember'; export default Ember.Service.extend({ store: Ember.inject.service(), resources: null, init() { this.set(

exception while importing module in ember js

不羁岁月 提交于 2020-01-06 03:30:07
问题 I need to remove diacritics from string in emberjs app. I found a plugin for this: fold-to-ascii but I don't know how to use it in my app. I added this plugin via npm and it is visible under node_modules folder in my app In docs usage of this plugin is: var foldToAscii = require("fold-to-ascii"); foldToAscii.fold("★Lorém ïpsum dölor.") but i get an exception: Uncaught Error: Could not find module fold-to-ascii also tried importing it like @Kori John Roys suggested: import foldToAscii from

Ember.js generate html from json with iteration

自闭症网瘾萝莉.ら 提交于 2020-01-06 03:21:47
问题 I'm supposed to use ember.js for a project. I'm converting a json into a HTML view. The json looks something like this: { "title": "Some H1 title", "children": [ {"title": "Some H2 title", "children": ..... } ] } So the result should look like Some H1 Title Some H2 Title Doesn't really matter if it's dynamic with handlebars or static. What is the recommended emberjs way of doing this? Load the whole json into a data model and go from there? Or just give the object to handlebars? (there is the

Action bubbling in Ember

試著忘記壹切 提交于 2020-01-06 02:21:07
问题 I am relatively new to Ember so forgive me if the answer to this question is obvious. I started a new job recently and I thought their approach to action bubbling was...curious. This is a big application with a lot of deeply nested components. To bubble actions up to the controller, they have been using this sort of thing a lot: actionName (parameter) { this.attrs.actionName(parameter); }, This will then bubble one level up to the next component, where they will call the same action again .

phantomjs not showing form fields

白昼怎懂夜的黑 提交于 2020-01-05 19:21:10
问题 I am using following js script to phantomjs on ember site running locally: //test_phantomjs.js require('phantomjs-polyfill'); var page = require('webpage').create(); page.open('http://localhost:4200/', function(status) { console.log("Status: " + status); if(status === "success") { page.render('example.png'); } phantom.exit(); }); The command I run the test this script is as follow: phantomjs --remote-debugger-port=9001 --remote-debugger-autorun=yes test_phantomjs.js I am suppose to get login

Ember Js Adding A Model Which is Dynamically Rendered On the UI

 ̄綄美尐妖づ 提交于 2020-01-05 12:58:36
问题 Hi all I have an issue i want to add another item to my model that is dynamically rendered on the UI. However after i add it It still doest render on the UI. Do I need to call a function after adding it to the list of models? Here is an example: http://emberjs.jsbin.com/mugodifiki/edit?html,js,output on clicking on an image it is suppose to add a predefined model to the array and display it on the UI 回答1: This is clearly an issue caused from the integration with owlcarousel library. A simple

Can I add an additional computed property to an Ember ArrayProxy?

跟風遠走 提交于 2020-01-05 12:13:20
问题 I'm working on a legacy Ember app that has a bit of a funky setup and I'm trying to clean things up and follow conventions a bit more. One issue is that, rather than returning an array from the model hook of an index route, we're returning an object that contains an array. So, I'm wrapping the model in an ArrayProxy in setupController like this: setupController: (controller, model) -> model_proxy = Ember.ArrayProxy.create({content: model.get('item')}) controller.set('content', model_proxy)

Ember Mocha tests fail when async (using ember-mocha-adapter)

久未见 提交于 2020-01-05 12:07:29
问题 I can't get mocha working with Ember due to the fact that it fails when a test of the following nature is executed: describe('Location Panel', function () { beforeEach(function () { App.reset(); visit('/map/41.76721,-72.66907'); }); it('Have proper address', function () { var $title = find('.panel-header h2'); expect($title).to.have.text('476 Columbus Blvd, Hartford'); }); }); Basically it can't find any of the DOM elements, because it runs the test before the route has finished loading.. The

How does the SANE stack represent parent/child relationships on a single model

别等时光非礼了梦想. 提交于 2020-01-05 11:37:54
问题 How do I represent a parent/child relationship on the same model? An example of this is a model representing a folder. A parent folder can have many children folders. But a child folder can only have one parent folder. Ember.js has the concept of reflexive relations. I would like to implement the first option. "... explicitly define the other side, and set the explicit inverse accordingly ..." How would I go about setting that up on the sails.js side of the SANE stack? 回答1: I'm not sure what

Ember Restore State when Routing

北城以北 提交于 2020-01-05 10:30:14
问题 I have a application controller with a input bound to searchTerms and on click I am routing to search-results route. The code is from a book Rocknrollcall.Router.map(function() { // Add your routes here this.route('search-results', { path: 'search/:term' }); }); }); Rocknrollcall.ApplicationController = Em.ObjectController.extend({ searchTerms: '', actions: { submit: function() { this.transitionToRoute('search-results',this.get('searchTerms')); } } }); In the route I am returning some data I