ember.js

How do I setup the api-stub in an ember-cli app?

半世苍凉 提交于 2019-12-18 12:32:27
问题 I’m setting up a basic app using ember-cli and am running into trouble with the api-stub with ember-data. I've referenced the api-stub README and have referenced the ember guides, but can't figure out what I'm missing. I’m a bit of a noob, so forgive any obvious oversights on my part. Here's my setup... /api-stub/routes.js server.get('/listings', function(req, res) { var listing = { "listing": [{ "id": 1, "title": "Sunny 1-bedroom", "unit_type": "1br / 1ba", "description": "Roomy 1-bedroom

How to return a promise composed of nested models in EmberJS with EmberData?

不羁岁月 提交于 2019-12-18 12:30:15
问题 Enviroment # Ember : 1.4.0 # Ember Data : 1.0.0-beta.7+canary.b45e23ba Model I have simplified my use case to make the question easier to understand and anwser. Let's assume we have 3 models: Country , Region and Area : Country: - id: DS.attr('number') - name: DS.attr('string') - regions: DS.hasMany('region') Region: - id: DS.attr('number') - name: DS.attr('string') - country: DS.belongsTo('country') - areas: DS.hasMany('area') Area: - id: DS.attr('number') - name: DS.attr('string') - region:

How to (De)serialize field from object based on annotation using Jackson?

喜欢而已 提交于 2019-12-18 12:28:28
问题 I need to configure Jackson in a specific way which I'll describe below. Requirements Annotated fields are serialized with only their id: If the field is a normal object, serialize its id If the field is a collection of objects, serialize an array of id Annotated fields get their property names serialized differently: If the field is a normal object, add "_id" suffix to property name If the field is a collection of objects, add "_ids" suffix to property name For the annotation I was thinking

can we view all the routes in emberjs aka something similar to what rake routes does in rails

淺唱寂寞╮ 提交于 2019-12-18 12:24:11
问题 As the routes file in emberjs is becoming large, I am finding it difficult to keep track of all the routes supported by emberjs app, rake routes in rails gives a list of routes in the rails app, is there a way to generate routes in similar fashion for emberjs? 回答1: Currently you can access all existing routes with App.Router.router.recognizer.names or just the names using Ember.keys(App.Router.router.recognizer.names) . It's obviously not as extensive as the Rails routes but it gives a quick

How to create a custom Serializer for Ember data

假如想象 提交于 2019-12-18 12:00:56
问题 I have an API that returns JSON that is not properly formatted for Ember's consumption. Instead of this (what ember is expecting): { events: [ { id: 1, title: "Event 1", description: "Learn Ember" }, { id: 2, title: "Event 2", description: "Learn Ember 2" } ]} I get: { events: [ { event: { id: 1, "Event 1", description: "Learn Ember" }}, { event: { id: 2, "Event 2", description: "Learn Ember 2" }} ]} So if I understood correctly, I need to create a custom Serializer to modify the JSON. var

How to create a custom Serializer for Ember data

拈花ヽ惹草 提交于 2019-12-18 12:00:02
问题 I have an API that returns JSON that is not properly formatted for Ember's consumption. Instead of this (what ember is expecting): { events: [ { id: 1, title: "Event 1", description: "Learn Ember" }, { id: 2, title: "Event 2", description: "Learn Ember 2" } ]} I get: { events: [ { event: { id: 1, "Event 1", description: "Learn Ember" }}, { event: { id: 2, "Event 2", description: "Learn Ember 2" }} ]} So if I understood correctly, I need to create a custom Serializer to modify the JSON. var

Set custom data- attributes on {{#linkTo}} helper <a> tag

余生颓废 提交于 2019-12-18 11:46:02
问题 How can I set custom data- attribute on the {{#linkTo}} helper? I want use this: {{#linkTo "foo" data-toggle="dropdown"}}foo{{/linkTo}} and the result should look like this: <a id="ember323" class="ember-view active" data-toggle="dropdown" href="#/foo/123">foo</a> but it looks like: <a id="ember323" class="ember-view active" href="#/foo/123">foo</a> How can I do this? 回答1: A way you could do this is to extend your Ember.LinkComponent to be aware of the new attribute: Ember.LinkComponent

Does ember.js encourage too many controllers?

怎甘沉沦 提交于 2019-12-18 11:08:28
问题 I am trying to understand the best practices for structuring an ember.js application. This slide from tomdale: https://speakerdeck.com/u/tomdale/p/emberjs-more-than-meets-the-eye?slide=55 has a concise description of how to apportion the application logic. However in trying to follow these guidelines I have finding some problems: The router is growing too large. According to the presentation the router "responds to events from views", but this results in a lot of code when there are dozens of

Don't the data attribute options used in Bootstrap, Angular.js, and Ember.js conflict with Unobtrusive Javascript principles? [closed]

女生的网名这么多〃 提交于 2019-12-18 10:39:50
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I've always been told it's good practice (ala 'unobtrusive javascript') separate JavaScript from HTML markup. However, I've been seeing the opposite trend with a number of new and popular frameworks such as Bootstrap, Angular.js, and Ember.js. Can someone tell me why this isn

Drag&Drop with Ember.js

♀尐吖头ヾ 提交于 2019-12-18 10:17:30
问题 Is there an example on how to implement Drag and Drop with Ember.js ? I have tried using jQuery UI, but the integration seems to be somewhat complex. I've seen this jsFiddle: http://jsfiddle.net/oskbor/Wu2cu/1/ but haven't been able to implement this successfully in my own app. What are the options for a rather simple drag&drop implementation using Ember.js ? 回答1: I took a look at the post by Remy Sharp and implemented a basic example in Ember.js, see http://jsfiddle.net/pangratz666/DYnNH/.