ember.js

How to get Ember Twiddle working: Route links are not displaying on the page

我们两清 提交于 2020-04-17 20:05:47
问题 This question is related to: Ember Octane How to Clear Form Errors? I have been asking a lot of questions on how to upgrade my Ember Classic project to Ember Octane. Some users in the community have suggested that I post an Ember-Twiddle for them to see what is going on. I have tried doing that, but I cannot get it to work. This is another tool for me to learn and I am struggling a bit to make heads or tails of it while trying to also NOT post my entire project as that seems unnecessary. Why

How to get Ember Twiddle working: Route links are not displaying on the page

a 夏天 提交于 2020-04-17 20:01:38
问题 This question is related to: Ember Octane How to Clear Form Errors? I have been asking a lot of questions on how to upgrade my Ember Classic project to Ember Octane. Some users in the community have suggested that I post an Ember-Twiddle for them to see what is going on. I have tried doing that, but I cannot get it to work. This is another tool for me to learn and I am struggling a bit to make heads or tails of it while trying to also NOT post my entire project as that seems unnecessary. Why

Ember.js 入门指南——枚举(enumerables)

不打扰是莪最后的温柔 提交于 2020-04-07 06:36:56
本系列文章全部从( http://ibeginner.sinaapp.com/ )迁移过来,欢迎访问原网站。 在 Ember 中,枚举是包括若干子对象的对象,并且提供了很多的 Ember.Enumerable API 获取所包含的子对象。我们常见的枚举都是基于原生的 javascript 数组实现的, Ember 扩展了其中的很多接口。 Ember 提供一个标准化接口处理枚举,并且允许开发者完全改变底层数据存储,而无需修改应用程序的其他部分去访问它。 Ember 的 Enumerable API 尽可能的遵照 ECMAScript 规范。为了减少与其他库不兼容 Ember.js 允许你使用本地浏览器实现数组。 下面是一些重用的 API 列表;请注意左右两列的不同。 标准方法 可被观察方法 说明 pop popObject 该函数从从数组中删除最后项,并返回该删除项。 push pushObject 新增元素 reverse reverseObject 颠倒数组元素 shift shiftObject 把数组的第一个元素从其中删除,并返回第一个元素的值 unshift unshiftObject 可向数组的开头添加一个或更多元素,并返回新的长度。 详细文档请看: http://emberjs.com/api/classes/Ember.Enumerable.html

Ember.js 入门指南——表单元素

烂漫一生 提交于 2020-04-07 05:57:51
文章从( http://ibeginner.sinaapp.com)迁移过来,欢迎访问原页面。 Ember 提供的表单元素都是经过封装的,封装成了 view 组件。经过解析渲染之后就会生成普通的 HTML 标签。更多详细信息你可以查看他们的实现源码: Ember.TextField 、 Ember.Chechbox 、 Ember.TextArea 。 按照惯例,先创建一个 route : ember generate route form-helper 。 1 , input 助手 {{! //app/templates/form-helper.hbs }} {{input name="username" placeholder="your name"}} 其中可以使用在 input 助手上的属性有很多,包括 readonly 、 value 、 disabled 、 name 等等,更多有关的属性介绍请移步 官网介绍 。 注意:对于使用在 input 助手上的属性是不是使用双引号括住是有区别的。比如 value=”helloworld” 和 value=helloworld 渲染之后的结果是不一样的,第一种写法是直接把 “helloworld” 这个字符串赋值设置到 value 上,第二种写法是从上下文获取变量 helloworld 的值再设置到 value 上,通常是在

Why won't my tracked array update in Ember Octane?

怎甘沉沦 提交于 2020-03-21 03:55:07
问题 I'm trying out Octane, and for some reason, if I show an array in a template and I add a new object to it, the UI doesn't update. What am I doing wrong? Here is my template: <label for="new-field-name">Field Name</label> <Input id="new-field-name" @value={{this.newFieldName}} type="text" /> <button {{on "click" this.addField}}>Add field</button> {{#each this.fields as |field|}} <p>{{field.name}}</p> {{/each}} And the component: import Component from '@glimmer/component'; import { tracked }

Error evaluating App.Product.findQuery

ε祈祈猫儿з 提交于 2020-03-05 07:59:10
问题 I'm trying to get data from an API like this: App.Store = DS.Store.extend({ revision: 12, adapter: DS.RESTAdapter.create({ host: 'http://api.my-api/v1/products(name=my-name)' }) }); App.Product = DS.Model.extend({ name: DS.attr('string') }); App.ApplicationRoute = Ember.Route.extend({ model: function () { return App.Product.findQuery({show: 'sku,name', format: 'json', apiKey: 'MyApIkEy123'}); } }); The error I get in the console is: Error while processing route: index undefined is not a

Removing Classnames from Ember view

泪湿孤枕 提交于 2020-02-25 08:41:25
问题 I am trying to create view that has functionality described in a view in am extending, but with different class names. What is happening is the ExpTypesView classes are ['nav','nav-pills'] and ['nav','nav-tabs']. How do i set it so they replace the classnames set in NavView? Resume.NavView = Em.View.extend({ tagName: 'ul', classNames: ['nav','nav-tabs'], currentPathDidChange: function(){ Ember.run.next( this, function() { $("ul li:has(>a.active)").addClass('active'); $("ul li:not(:has(>a

Reentering a route doesn't load content

心已入冬 提交于 2020-02-24 11:37:31
问题 I've got a route set up like this: App.UserRoute = Ember.Route.extend({ renderTemplate: function() { this.render('settings/user', {into: 'application', controller: 'User'}); this.render('settings/user_left', {outlet: 'left_menu'}); }, setupController: function(controller, user){ this.controllerFor('users').set('content', App.User.find()); } } Controller is: App.UsersController = Ember.ArrayController.extend(); App.UserController = Ember.ObjectController.extend({ needs: 'users', contentBinding

Ember data not loading belongsto relationship using fixtures

最后都变了- 提交于 2020-02-22 06:12:24
问题 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:09:35
问题 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