ember.js

Getting error: You need to pass a model name to the store's modelFor method

主宰稳场 提交于 2019-12-23 13:01:15
问题 Using Ember 2.6.0 Have the following routes defined: Router.map(function() { this.route('brands'); this.route('brand', {path: '/brands/:brand_id'}); }); The model for brand is: export default Model.extend({ name: attr('string'), description: attr('string'), dateCreated: attr('date'), lastUpdated: attr('date'), regions: hasMany('region') }); And the model for region is: export default Model.extend({ name: attr('string'), dateCreated: attr('date'), lastUpdated: attr('date'), brand: belongsTo(

in ember how to create a class method on Ember.Object.extend that can work to access a json service

怎甘沉沦 提交于 2019-12-23 12:52:44
问题 Sorry to ask such a simple question but I'm looking at migrating from jQuery to Ember and am trying to figure out calling / responding json without using ember-data. One question I have is how do people suggest having class methods. Say for example I have a post object like this: Hex.Post = Ember.Object.extend({ id: null, body: null }); Would a reasonable findById look like this? $(document).ready(function(){ Hex.Post.findById=function(id){ console.log("you are here"); $.getJSON("/arc/v1/api

How can clear form data in ember js

旧街凉风 提交于 2019-12-23 12:46:47
问题 Hi i am very new to ember js. i wrote a form for new employee entry.and send data through route.Data saved successfully. But the problem is after form submission my form data not cleared. The code as follows: app.js: App.Router.map(function() { this.resource('saveprofile', { path: '/saveprofile/:profiledata'}); }); App.NewprofileController = Ember.ObjectController.extend({ id:'', name: '', designation: '', saveProfileAction: function () { profiledata = [{ "id": this.get("id")}, {"name": this

Post to Rails from Emberjs using JSONAPI adapter, Rails not seeing the params

断了今生、忘了曾经 提交于 2019-12-23 12:21:07
问题 I am trying to save a message model in Emberjs. I am using the JSONAPIAdapter and JSONAPISerilzier. My post to rails hits the right controller and action as a post, but if I look inside with Pry, the data attributes are not there. My payload: {"data":{"attributes":{"body":"Why","user_id":"17"},"relationships":{"user":{"data":null},"conversation":{"data":null}},"type":"messages"}} Content-Type:application/vnd.api+json Rails params in the Rails console: {"format"=>"json", "controller"=>"api/v1

Ember js use handlebars helper inside a controller?

久未见 提交于 2019-12-23 12:16:23
问题 I have a helper method that maps a number to a text - Ember.Handlebars.helper('getStatusText', function (value, options) { switch(value) { case 1: return "Fresh"; break; case 2: return "Callback"; break; default: return "Unable to get Status"; } }); I am able to use the helper in the view by using {{getStatusText 1}} But how do I use the helper in an action inside an ObjectController ? Test.DealController = Ember.ObjectController.extend({ selectedStatusType: null, statusList: ["Fresh",

Ember not updating the view on model change

萝らか妹 提交于 2019-12-23 11:50:03
问题 This fiddle has the starter kit recreated, with and extra button that alters the model. http://jsfiddle.net/UjacC/1/ However, when clicking change, the array changes, but the view is not being updated. Why? <title>Ember Starter Kit</title> <body> <script type="text/x-handlebars"> <h2>Welcome to Ember.js</h2> <button id="btnChange">change model</button> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="index"> <ul> {{#each item in model}} <li>{{item}}</li> {{/each}} <

How to use EMBER.SORTABLEMIXIN?

做~自己de王妃 提交于 2019-12-23 10:53:30
问题 My FIXTURES contains array of products which i want to sort based on ID. Astcart.Application.FIXTURES=[ { "name" : "astr", "home_products": [ { "id": 3, "name": "Mobiles & Accessories" }, { "id": 2, "name": "Mobiles & Accessories" }, { "id": 1, "name": "Mobiles & Accessories" } ] } ]; I am not getting complete example of EMBER.SORTABLEMIXIN .I don't have any idea about sorting in ember. Can anyone explain me how to do sorting in ember using my this example(Not working)? 回答1: The sortable

ember-cli served via virtual box violates content security policy

戏子无情 提交于 2019-12-23 10:47:07
问题 I have a fresh ember-cli v.0.1.2 application. I serve ember within virtual box, and access the webpage from the host machine via Host-Only configured network adapter, at 192.168.56.102 . When I run ember serve from the virtual box and visit 192.168.56.102 from the host, I get these errors on the console: [Report Only] Refused to load the script 'http://192.168.56.102:35729/livereload.js?snipver=1' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe

Ember Data bulk saves to server

南楼画角 提交于 2019-12-23 10:17:45
问题 Ember Data is moving fast from version to version and the method for saving data has been changing along with it. Right now with version 1.0.0-beta.8.2a68c63a the proper method is to update a record and then do a record.save() to trigger a PUT request back to the server. With my current app I'm updating multiple records at once and that could involve 50+ PUT ajax requests back to the server. We're concerned about performance and efficiency issues and haven't found any documentation for doing

ember.js show default nested route if none provided

谁说胖子不能爱 提交于 2019-12-23 10:10:50
问题 In my ember app (1.0.0 production version) I have a URL structure as follows: /item /item/{specific-item-name-defined-in-routes} The Router mapping looks a little like this: App.Router.map(function () { this.resource("item", function () { this.resource("my-first-item"); this.resource("another-item"); ... }); }); If the user navigates to /item I want to display a specific post (e.g. /item/my-first-item ). I can do this by using the redirect method of the route: App.ItemRoute = Ember.Route