ember.js

Ember data not loading belongsto relationship using fixtures

孤街醉人 提交于 2020-02-22 06:06:56
问题 I am working on a very basic ember app , but I can't seem to get it to display the belongsto model. My user model: News.User = DS.Model.extend({ username: DS.attr('string'), items: DS.hasMany('News.Item') }); News.User.FIXTURES = [ { "id": 1, "username": "Bobba_Fett", "items": [1,2] }] My item model: 'use strict'; News.Item = DS.Model.extend({ title: DS.attr('string'), url: DS.attr('string'), domain: DS.attr('string'), points: DS.attr('number'), comments: DS.hasMany('News.Comment'), user: DS

Ember data not loading belongsto relationship using fixtures

拈花ヽ惹草 提交于 2020-02-22 06:05:36
问题 I am working on a very basic ember app , but I can't seem to get it to display the belongsto model. My user model: News.User = DS.Model.extend({ username: DS.attr('string'), items: DS.hasMany('News.Item') }); News.User.FIXTURES = [ { "id": 1, "username": "Bobba_Fett", "items": [1,2] }] My item model: 'use strict'; News.Item = DS.Model.extend({ title: DS.attr('string'), url: DS.attr('string'), domain: DS.attr('string'), points: DS.attr('number'), comments: DS.hasMany('News.Comment'), user: DS

Embedded ember-cli project conflicts with RequireJS

浪子不回头ぞ 提交于 2020-02-20 09:22:10
问题 I'm trying to embed an EmberJS application into a large portal application which uses extensively the RequireJS library. I'm using ember-cli to build the project. The built application consists of two files, dist/assets/vendor.js and dist/assets/myapp.js . The EmberJS application works after embedding it but the portal app's javascript breaks. After some research I've found out the problem is that vendor.js defines its own variables require , requirejs , requireModule and define which

How can we get the original event in ember's action

旧时模样 提交于 2020-02-10 01:52:00
问题 I'm updating a personal project where I used the ember.js version 0.9.x. So a new version was released and I have a problem related with ember action. I have the following html code: <li><a href="#" id="startApp" {{action activateView target="view"}}> Home</a> <span class="divider">|</span></li> where, when I click its call this function activateView: activateView: function(event, context) { console.log(event); } but the event and the context are undefined. I've already tried this.context and

How can we get the original event in ember's action

给你一囗甜甜゛ 提交于 2020-02-10 01:50:06
问题 I'm updating a personal project where I used the ember.js version 0.9.x. So a new version was released and I have a problem related with ember action. I have the following html code: <li><a href="#" id="startApp" {{action activateView target="view"}}> Home</a> <span class="divider">|</span></li> where, when I click its call this function activateView: activateView: function(event, context) { console.log(event); } but the event and the context are undefined. I've already tried this.context and

How to translate a dynamic key with I18n.js

流过昼夜 提交于 2020-02-07 05:34:49
问题 While implementing a multi language web application with Ember I had the need to use strings that would be translated to the language of the user's choice. For Ember there is I18n.js that does just that. It provides a Handlebars helper that takes a key string and handles the translation: {{t login.username }} would lookup the key "login.username" and replace it with the current language's corresponding text. My problem is that this helper takes a literal string value and does the lookup with

How to translate a dynamic key with I18n.js

左心房为你撑大大i 提交于 2020-02-07 05:34:26
问题 While implementing a multi language web application with Ember I had the need to use strings that would be translated to the language of the user's choice. For Ember there is I18n.js that does just that. It provides a Handlebars helper that takes a key string and handles the translation: {{t login.username }} would lookup the key "login.username" and replace it with the current language's corresponding text. My problem is that this helper takes a literal string value and does the lookup with

Bind html string in controller to template does not trigger click event

扶醉桌前 提交于 2020-02-06 10:14:31
问题 I have a html string in controller and I bind this to view, but the action does not trigger on clicking. I already applied the triple braces or htmlSafe to avoid html escape, the button shows on the template but when clicking on it does not trigger action newAlert ## hello.js import { htmlSafe } from '@ember/string'; import { computed } from '@ember/object'; export default Controller.extend({ htmlString: computed(function() { return htmlSafe('<button {{action "newAlert"}}>Test Alert</button>'

Bind html string in controller to template does not trigger click event

谁都会走 提交于 2020-02-06 10:13:53
问题 I have a html string in controller and I bind this to view, but the action does not trigger on clicking. I already applied the triple braces or htmlSafe to avoid html escape, the button shows on the template but when clicking on it does not trigger action newAlert ## hello.js import { htmlSafe } from '@ember/string'; import { computed } from '@ember/object'; export default Controller.extend({ htmlString: computed(function() { return htmlSafe('<button {{action "newAlert"}}>Test Alert</button>'

Bind html string in controller to template does not trigger click event

匆匆过客 提交于 2020-02-06 10:12:27
问题 I have a html string in controller and I bind this to view, but the action does not trigger on clicking. I already applied the triple braces or htmlSafe to avoid html escape, the button shows on the template but when clicking on it does not trigger action newAlert ## hello.js import { htmlSafe } from '@ember/string'; import { computed } from '@ember/object'; export default Controller.extend({ htmlString: computed(function() { return htmlSafe('<button {{action "newAlert"}}>Test Alert</button>'