ember.js

Is there a way to pass an array to currentWhen in EmberJS?

不打扰是莪最后的温柔 提交于 2019-12-30 08:31:47
问题 I'm trying to make a link stay 'active' on multiple routes, such as /#/users and /#/user. Any ideas? 回答1: You can reopen Ember's LinkView and do something like this (allows currentWhen to contain space delimited values) Ember.LinkView.reopen({ active: function() { // we allow link-to's currentWhen to specify multiple routes // so we need to check each one of them var loadedParams = Ember.get(this, 'loadedParams'); var currentWhen = this['current-when'] || this.currentWhen; currentWhen =

How to disable deprecation warnings in Ember.js?

醉酒当歌 提交于 2019-12-30 08:03:00
问题 I've written up an application that uses Ember Data. It's passing all it's tests and running as expected, however, something is causing a repeated deprecation warning to be thrown into console. I'd like to know how to disable these warnings in Ember. 回答1: You can just do Ember.deprecate = function(){} in your application.js file and that should disable ember deprecation warnings. 回答2: It's always good to consider deprecations, but if you want to just turn them off entirely add the following 2

Emberjs: Get the current element

左心房为你撑大大i 提交于 2019-12-30 07:51:52
问题 I am looking for something that's similar to the this of jQuery . I'm going to list below the code I have: <script type="text/x-handlebars" data-template-name="uiMainContainerTaskList"> <div class="uiMainContainerTaskListContent"> {{#view App.TasksView}} {{#each App.tasksController.tasks}} <div class="uiMainContainerWideItem" {{action "taskClick" target="TasksView" on="click"}}> <div class="uiMainContainerWideItemCheckbox">{{view Em.Checkbox checkedBinding="isDone"}}</div> <div class=

Facebook Like Box not loading on Ember app

冷暖自知 提交于 2019-12-30 07:42:27
问题 I'm trying to get the like box to work inside our ember app, in a template called about . The problem is that if I enter the ember app from another route (instead of about route), then navigate to the about route with link-to helpers, then the like box is not rendered. Instead, if I enter/refresh the about route directly, it renders just fine. Any ideas on how to make it render even if somebody navigates to that route from another route ? templates/about.hbs: ... <div class = "fb-like-box"

Facebook Like Box not loading on Ember app

一个人想着一个人 提交于 2019-12-30 07:42:08
问题 I'm trying to get the like box to work inside our ember app, in a template called about . The problem is that if I enter the ember app from another route (instead of about route), then navigate to the about route with link-to helpers, then the like box is not rendered. Instead, if I enter/refresh the about route directly, it renders just fine. Any ideas on how to make it render even if somebody navigates to that route from another route ? templates/about.hbs: ... <div class = "fb-like-box"

Ember.js Chosen integration

杀马特。学长 韩版系。学妹 提交于 2019-12-30 06:48:43
问题 I've done a sample Ember.js integration with Chosen (https://github.com/harvesthq/chosen) Coffeescript: App.ChosenSelectView = Em.Select.extend({ didInsertElement: -> @_super() @$().chosen() # Assumes optionLabelPath is something like "content.name" @addObserver(@get("optionLabelPath").replace(/^content/, "content.@each"), -> @contentDidChange()) contentDidChange: -> # 2 ticks until DOM update Em.run.next(this, (-> Em.run.next(this, (-> @$().trigger("liszt:updated"))))) }) The thing that

How to store the user in a session

若如初见. 提交于 2019-12-30 06:45:47
问题 I am trying to set up ember-simple-auth with a django-rest-framework backend, but I'm running into some trouble saving the user to the session. I have to be able to do something like this in my templates: <h2>Welcome back, {{session.user}}</h2> So following several guides I found, I have got the authentication and authorization working so that I can get a valid token and use is in requests. To get the user on the session, I have modified App.CustomAuthenticator.authenticate so that when the

How to store the user in a session

橙三吉。 提交于 2019-12-30 06:45:03
问题 I am trying to set up ember-simple-auth with a django-rest-framework backend, but I'm running into some trouble saving the user to the session. I have to be able to do something like this in my templates: <h2>Welcome back, {{session.user}}</h2> So following several guides I found, I have got the authentication and authorization working so that I can get a valid token and use is in requests. To get the user on the session, I have modified App.CustomAuthenticator.authenticate so that when the

Shared state in Ember component

允我心安 提交于 2019-12-30 06:43:04
问题 I was trying to build a simple list with append widget as an Emberjs component. The following is the code I used: HTML: <!DOCTYPE html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0/ember.min.js"></script> <meta charset=utf-8 /> <title>Ember Component example</title> </head> <body>

Execute code once after all views have completely rendered in Ember.js

守給你的承諾、 提交于 2019-12-30 06:20:46
问题 Something like document ready, but after all Ember views rendering I am doing this right now with an override on ApplicationView didInsertElement, which seems to be working so far: App.ApplicationView = Em.View.extend({ didInsertElement: function() { // Do your magic. } }); I am wondering if this is the right way for an Ember document ready, or if Ember has a more native support for this simple and very common thing. 回答1: You can easily add a "post render" hook by reopening the base View