ember.js

what is the correct way to use coffeescript with ember´s Mixins?

只愿长相守 提交于 2019-12-12 17:01:10
问题 Apologies for my english, I am trying to extend a View with a mixin. The code is coffeescript : View - films_film_view.js.coffee App.FilmsFilmView = Em.View.extend App.ModalViewMixin, templateName: 'films/show' Mixin - modal_view_mixin.js.coffee App.ModalViewMixin = Em.Mixin.create modalView: null click: -> @showModalView() close: -> @closeModalView() closeModalView: -> if @modalView @modalView.close() showModalView: -> @closeModalView() @modalView = @createModalView() if @modalView

“Can't verify CSRF token authenticity” when testing emberjs/rails/devise app using qunit

 ̄綄美尐妖づ 提交于 2019-12-12 16:49:46
问题 I have a emberjs/rails application using devise for user authentication. I am building integration tests using qunit. I manually log into the app before I run tests. GET requests can be processed during tests, but POST requests fail. In particular, when making a POST request, I'm getting a "Can't verify CSRF token authenticity" error from devise. When I reload tests, I am logged out of app. How do I get qunit to play nice with devise? 回答1: You need to add csrf_meta_tags to the index.html.erb

How to handle a 400 error with Ember Data (2.4.0-canary)

巧了我就是萌 提交于 2019-12-12 15:42:33
问题 I can't figure out if my problem has to do with my query or my response or something else. In my route I'm using a queryRecord : model(params) { return this.store.queryRecord('invitation', { 'invitation_token' : params.invitationToken }); }, I'm properly receiving on the server side but I'm testing the case where the invitation token no longer exists. Therefore, the server is returning a 400 with a json payload which has an explanation of the error. {"error":"Error finding invitation"} But

How can you manually toggle a Foundation 5 dropdown in javascript (inside an emberjs app)?

蹲街弑〆低调 提交于 2019-12-12 15:08:04
问题 I am having issues getting a dropdown to be bound properly in an ember js app because I have action handlers on click inside of the list and the foundation events are conflicting. Template name: <a data-dropdown="groupDrop" id="groupDropdownLink" class="button radius tiny success dropdown"> Move Selected To Group ({{selectedCount}}) </a> <br> <ul id="groupDrop" data-dropdown-content class="f-dropdown"> {{#each eventGroups}} <li {{action 'moveToGroup' this}}><a>{{name}}</a></li> {{/each}} </ul

How to select radio button and select option with ember integration tests?

不打扰是莪最后的温柔 提交于 2019-12-12 15:02:13
问题 How to select a radio button in and a particular select option with ember integration tests? I know how to use the click one and the fillIn for inputs. http://guides.emberjs.com/v1.10.0/testing/test-helpers/ 回答1: Radio button: click('css selector'); For the select say you have: <select> <option>red pill</option> <option>blue pill</option> </select> In your test: fillIn('css selector', 'red pill'); 来源: https://stackoverflow.com/questions/29303120/how-to-select-radio-button-and-select-option

Ember.js - How to handle error with DS.store.findRecord() method

你。 提交于 2019-12-12 14:44:41
问题 I am using following simple code to retrieve user from server. var someUser = this.store.findRecord('user', 0); I am using this for retrieving the user. if user is not found on 0 id, server returns 404. and error as per json api. but how do i know about error on client side about it ? 回答1: Taken from Ember guides: Use store.findRecord() to retrieve a record by its type and ID. This will return a promise that fulfills with the requested record. Since the return value is a promise, you can use

Implementing custom ajax calls when loading data in model

我只是一个虾纸丫 提交于 2019-12-12 14:44:15
问题 In my Emberjs application I have an Employee model which I should load through a REST Get API call, where I have to authenticate the API first for a token then start loading the data, I know how to do this easily using JQuery but not sure how I can implement this in EmberJS, so I will appreciate it so much if anyone can instruct me how to do so. Below is the JQuery code I use for authentication, extracting the employees data, as well as my EmberJS model code Thanks Authentication: $.ajax ({

How to delete all data from Ember Data store? [duplicate]

自古美人都是妖i 提交于 2019-12-12 13:58:50
问题 This question already has answers here : Ember.js Data how to clear datastore (7 answers) Closed 6 years ago . In the Ember.js application I'm working on, that uses Ember-data, once the user gets to a point on the screen, I want to delete all state stored in the ember-data Store associated with the application, and start with a clean slate that can start pulling data from the server. Anyone know how to do it? 回答1: I don't think there is an easy way. The only way ATM is loop over all your DS

Ember passing a model to transitionToRoute

我们两清 提交于 2019-12-12 13:33:46
问题 I'm using Ember-cli with ember 1.11 I'm trying to use the transitionToRoute method in a controller to transition to a route and feed it a dynamically generated object as the model. Here's my controller: import Ember from 'ember'; export default Ember.Controller.extend({ actions: { launch_scanner: function(){ console.log('launch_scanner'); var model = {name: "Edward", phone: "123", email: "email@test.com"}; //the final app will pull the model variable from a QR scanner this.transitionToRoute(

Ember-cli Pods & Loading Templates

↘锁芯ラ 提交于 2019-12-12 13:03:41
问题 I have created a loading template for my application that is working and I'm now trying to create custom loading templates for my routes and I can't it to work. Here is my file structure (using pods). - app - | pods - - | application - - - - adapter.js - - - - template.hbs - - | loading - - - - template.hbs - - | author - - - - model.js - - - | show - - - - controller.js - - - - route.js - - - - template.hbs - - - - | loading - - - - - - template.hbs Here is my router.js Router.map(function()