Quantcast
Channel: Ember.JS - Latest topics
Viewing all 4841 articles
Browse latest View live

Integration Testing components

$
0
0

@tsatsmt wrote:

I have a component text-console that I am trying to create an integration test for. Ember v 1.13.8

Usage: {{text-console content=message.title}}

hbs:

{{content.text}}

How can I pass the message.title.

Here is the model {message: { title: { text: 'message text' } }}

When running this.set I get a message saying this.set is not defined

this.set('message.title', {text: 'sample message text'});
or this.set('content', message) where message = {title: {text: 'some message'}}

Thanks for help.

this.render(hbs {{text-console content=message.title}} );

Posts: 3

Participants: 2

Read full topic


Hi, why i can't see row disapper in the inspector when i delete record?

$
0
0

@1111 wrote:

when i delete record from my model i can see in the inspector in the data that the number decreased, but in the right where all the rows from my data, is still show the row that i delete. did i do something wrong or this behavor is ok ?

Posts: 2

Participants: 2

Read full topic

Passing dynamic query-params as an object in link-to helper

$
0
0

@siva_abc wrote:

Hello, I have a requirement as to pass query-params dynamically.

I have demostrated my idea here

model: [ 
      {
      "routeName":"laptop",
      "param": {"color":"blue"}
      },
      {
      "routeName":"mobile",
      "param": {"size":"5.5"}
      },
      {
      "routeName":"notebook",
      "param": {"display":"HD"}
      }
    ];


{{#each model as |obj|}}

     {{#if (equal obj.routeName 'laptop')}}

          {{#link-to obj.routeName (query-params color=obj.param.color)}}
                {{obj.routeName}}
          {{/link-to}}

     {{/if}}

     {{#if (equal obj.routeName 'mobile')}}

           {{#link-to obj.routeName (query-params size=obj.param.size)}}
                {{obj.routeName}}
           {{/link-to}}

     {{/if}}

     {{#if (equal obj.routeName 'notebook')}}
           {{#link-to obj.routeName (query-params display=obj.param.display)}}
                {{obj.routeName}}
           {{/link-to}}
     {{/if}}

  {{/each}}

Since, {{link-to}} doesn't support dynamic querying I had to include checks for passing query-param.

If {{link-to supports dynamic passing of query-params like below

    {{#each model as |obj|}}

        {{#link-to obj.routeName (query-params obj.param) }}
              {{obj.routeName}}
       {{/link-to}}

    {{/each}}

The code would be more pretty without any if checks !

Posts: 1

Participants: 1

Read full topic

Passing routes to components

$
0
0

@spectras wrote:

I was wondering whether someone had a better plan for this problem.

I often find myself buidling components to list some data. For instance, they will look like:
{{article-list articles=section.articles delete=(action "delete")}}

The idea is I have several places that need to list articles, and they can do so neatly, using the dedicated component. So far so good.

Now, this listing often includes some actions and links. For instance, every line could include a view, rename, delete action. Such actions go up flawlessly… until some of them need to trigger routes.

How would I do that? I came up with the following solutions, but none seems very clean:

  • Forbid links. If triggering a route is needed, then pass an action from the controller, that will do this.transitionToRoute. Feels clumsy, but this is what I end up doing atm.
  • Pass the route name to the component. However, that means the component must be aware it is a route name and not an action.
  • I posted https://github.com/emberjs/rfcs/issues/105. I believe this would solve the issue by allowing passing (link-to) closures that would behave as actions.

But maybe there is another, better option?

Posts: 3

Participants: 2

Read full topic

Worried about what Ember 2.x will become

$
0
0

@Emrvb wrote:

My primary worry is about how we're supposed to be working with components in templates. In my opinion templates should only be used to define where and how something is rendered. I always aim on shielding templaters/designers from as much logic as possible. To me it seems the way we are supposed to use components (e.g. as replacement to the itemController) causes too much business/program logic to bleed into the templates. I'm afraid that in the future even small changes in the logic will have more impact on the templates and templaters/designers need far more understanding of the program internals than desired.

I try to have my applications seem like magic to the templaters/designers in the same way Ember is magic to me as a developer. Follow convention and you have to do almost nothing and add X when you want something more specific. I feel like I'm losing this ability.

If my worries have not merit at all, feel free to comfort me with rationale. If they do have merit, I'd love to discuss how we could address this issue.

Posts: 1

Participants: 1

Read full topic

Beginner tutorial building an app

$
0
0

@mtangoo wrote:

Am a beginner in Emberjs but no JS. Ihave worked with angular previously and would like to use Emberjs in my next project. However I can't yet find a tutorial that takes me thru by building a simple app.
Official docs are great but I always enjoy that kind of tutorials

Is there any?

Posts: 1

Participants: 1

Read full topic

Looking for a touch drag toggle button

$
0
0

@JordanRDesigns wrote:

I'm looking for something that looks and functions similar to this bootstrap toggle button

http://www.bootstraptoggle.com/

But required the user to drag it to toggle instead of just a tap. Has anyone seen something like this before and know what that's called?

I will eventually be turning this into an ember component and maybe addon if it works well.

Posts: 4

Participants: 2

Read full topic

CSS Struggles with Components

$
0
0

@jesmith wrote:

I am working on a new app using the AdminLTE template. One of the struggles I am currently facing is that when I take pieces and break them out into components (like the user-profile popup that is in the upper right corner) when Ember actually renders that, the wrapped div breaks my look and feel by not having correct CSS to not enforce it's on changes. Suddenly objects that weren't originally inside a div end up there due to the component work. And the ember-view class doesn't seem to do what's expected to minimize that (if that's what it's trying to do).

What's the best practice for making sure that making something a component doesn't create un-intended CSS issues?

Posts: 1

Participants: 1

Read full topic


Can't seem to get helper unit test to pass

$
0
0

@JordanRDesigns wrote:

I'm not sure what's happening here but I can't get the unit test generated for my handlebars helper to pass, even though it works when I actually test in development.

Here is the test

test('Returns a string pointing to the cropped version of an image', function(assert) {
  var result = croppedImage("5579-pkUaYMcLSn.png");
  console.log(result);
  assert.equal(result,'image-cropped.png');
});

And the code to make it pass (should be)

let image = params[0],
    index = image.indexOf('.');
var croppedImageValue = [image.slice(0, index), '-cropped', image.slice(index)].join('');
return croppedImageValue;

Like I said, this code works when testing in development but the unit test won't pass.

I found this stack overflow here

But I tried switching to the format he shows with the _rawFunction but that just tells me _rawFunction is not a function or something like that.

Posts: 1

Participants: 1

Read full topic

Toggle dynamically generated elements in template

$
0
0

@michaellee wrote:

Let's say I've got a list of students. I'm trying to figure out a way to show only a specific student in the list if one of the filter buttons is used. I'm not sure what property to even check for as indicated by the ??? below or how to really setup the action. This is what I've got so far. I'm not even sure if I'm on the right track.

//In a .hbs template
{{#each students as |student|}}
  {{#if ???}}
    {{student.name}}
  {{/if}}
{{/each}}


<b>Filter student</b>
{{#each students as |student|}}
  <div {{action toggleStudent student}}>{{student.name}}</div>
{{/each}}

//In corresponding controller to template
...
actions: {
  toggleStudent(student){
    this.toggleProperty("???")
  }
}
...

Posts: 1

Participants: 1

Read full topic

Ember compatibility with new Zurb Foundation for Sites

$
0
0

@jean wrote:

Any hints for a smooth transition to Foundation 6 or a good start for new users?

Posts: 1

Participants: 1

Read full topic

Upgrading to Ember Simple Auth 1.0 - ic-ajax authorization

$
0
0

@tschoartschi wrote:

Hey :smile:

As Ember Simple Auth is 1.0 now I wanted to upgrade. But I realized that they removed "auto-authorization". We are using ember-cli-ic-ajax and in our application we have many things like the following:

import Request from 'ic-ajax'; 
new Request(params).then(...)

Now I wonder what is the best way to authorize these ic-ajax requests without rewriting all the requests in the whole app.

@marcoow What do you think would be the approach with the tiniest impact on the existing codebase?

Thanks a lot, Tschoartschi

Posts: 3

Participants: 2

Read full topic

How to find relationships of any arbitrary ember-data model?

$
0
0

@shunchu wrote:

Is there a way to programmatically determine the relationships of an arbitrary ember-data model?

For example:

# basket
import DS from 'ember-data';
export default DS.Model.extend({
  fruits: DS.hasMany('fruit');
});

Is there an Ember way to get to fruits without knowing the model was basket beforehand?

Posts: 1

Participants: 1

Read full topic

Example of using ember-data in a service

$
0
0

@jesmith wrote:

I need to create a service that does data retrieval as it is data that will be used across mutliple routes (user-profile data).

I have a service created, and I have the ember-data store injected into it, but calls to the service from my components don't seem to trigger the data retrieval? I find lots of people alluding to this approach, but no examples of how it's done.

Does anyone have an example of a service being used to consume data from ember-data and make it accessible via a component?

I know routable components coming at some point makes this better, but I don't have any dates on when that is coming, and I need this functionality quickly.

Posts: 2

Participants: 2

Read full topic

Application integration and ember-cli

$
0
0

@spectras wrote:

So I have been thinking of converting our project to ember-cli, mostly in fear of being left out at some point, as development seems to turn more and more towards a total synergy between ember and ember-cli.

I installed all the dependencies, and now have a working ember command, that will generate a standalone application. Toying around with ember serve works and everything.

And I am at a loss: how can I integrate my application in a complete setup?

My application is normally delivered by a Django website. It is loaded from a dynamic webpage that provides a basic layout and embeds the required configuration (bootstrapping data, REST API settings and auth token, current username, locale, ...). The application cannot start without those.

I have been reading the documentation twice, and have absolutely no clue on how I am supposed to integrate ember-cli's building process in an external toolchain.

Or, basically, “how can I get rid of the coating and get a clean building process that takes my JS as input, and outputs a single JS file, and none of the cruft”? No html, no css, no vendor dependencies, just the application.

Posts: 4

Participants: 3

Read full topic


The Cost of Frameworks

$
0
0

@rovo79 wrote:

Hello, Paul Lewis wrote this great comparative analysis of JS Frameworks and Vanilla JS; The Cost of Frameworks. He used the TodoMVC as a baseline. I noticed he used Ember v1.10.0-beta.3 for his comparison. He said he used that instead of 2.20 because thats the latest thats on TodoMVC.

Do you think 2.20 would result in any better performance?

Posts: 3

Participants: 3

Read full topic

Work with records for a modal other than the current routes model

$
0
0

@JordanRDesigns wrote:

What would be the ember/ember-data way of creating a record for a record that is not the current routes record?

The scenario I have is I have an items route that finds is a list of items, when I click on one I transition to the item route which shows me all the info for that one item. I also have a bids resource but the way the bids will be worked with is always from an item route. So placing a bid happens on an item route.

So how would I go about tackling this? I was going to setup an ajax request in an action connected to my place bid button in the item route but I'm worried this might not be the ember way?

Posts: 12

Participants: 2

Read full topic

Ember observer not working when observes property of other controller

$
0
0

@Joao_Calvin wrote:

I want to access the IsOpen property that is set in my ApplicationController in my EventsController , but more than that , I want to listen for changes in it , so I'm using the following code :

isOpen: Ember.observer('application.isOpen', function () {
  console.log('test');
}),

But is not firing at all.

In my ApplicationController i have the following:

export default Ember.Controller.extend({
  isOpen: true,

  actions: {
      toggleSidebar () {
       this.toggleProperty('isOpen');
      }
   }
});

Am i missing some configuration?


UPDATE:

What i'm trying to do:

In my application template, i'm calling two components, the sidebar and the navbar component. In the navbar component, i have a button, each will send a action to ApplicationController, in order to make the sidebar toggle.

Like this:

ApplicationTemplate:

{{#if session.isAuthenticated}}
	{{pc-sidebar
		isVisible=showWrappers
		isOpen=isOpen
	}}
	{{pc-navbar
		isVisible=showWrappers
		isOpen=isOpen
		action='toggleSidebar'
	}}
{{/if}}
{{outlet}}

So, when i click in the button in my navbav, i send a action to ApplicationController:

actions: {
  toggleSidebar () {
     this.sendAction('action');
  }
}

And in my application controller, i just update the isOpen property:

  isOpen: true,
  actions: {
     toggleSidebar () {
       this.toggleProperty('isOpen');
     }
  }

Now the problem:

I need toggle the main too, each is wrapping all the content, BUT.... the MAIN is not in the application template, because only a few templates need it , that would be the case of EventTemplate:

<main class="main">
  <!-- content of event template here -->
</main>

So.. my solution was make the main a component, and call like this:

{{#main-main isOpen=isOpen}}
  <!-- content of event template here -->
{{/main-main}}

Now.. i need listen to isOpen that was define in ApplicationController, and i'm struggling with this..

Thanks.

Posts: 7

Participants: 2

Read full topic

Ember relationships and mongo relationships

$
0
0

@Joao_Calvin wrote:

I'm trying to figure out the best approach to my Ember App.

I'm working with two models: events and bookings, and in my database, I structured they totally separate and independent from each other.

Schemas:

Events:

attributes:
  date        : Date
  description : String
  hiw         : Object
  hour        : Date
  meeting     : String
  men         : Number
  name        : String
  women       : Number

  createdAt   : Date
  updatedAt   : Date

  isActive    :
    type    : Boolean
    default : false

type:
  type    : String
  default : 'event'

Bookings:

attributes:
  email         : String
  idiom         : String
  name          : String
  obs           : String
  participants  : Number
  phone         : String
  sex           : String
  vip           : String

  createdAt    : Date
  updatedAt    : Date

  isActive     :
    type    : Boolean
    default : false

type:
  type    : String
  default : 'booking'

As I'm learning Ember, I discovered that ember has relationships (belongsTo and hasMany), and I would like to ask if I should restructure my schemas to deal with Ember data, or if I should make them independent as i'm doing.

The tendency of bookings is be progressively more complex over time..

The Ember data relationships is for this kind of stuff, or is to simple things like, comments in posts.. etc. etc..

Thank you!

Posts: 5

Participants: 2

Read full topic

Using promises in a loop

$
0
0

@agolovan wrote:

I have the following "model" method at my route. I am going thought the collection of transfer objects and do some filtering which is actually removed for simplicity. However, if there is a flag for recurring transfer, I am doing call to App.TransferModel.fetchRecurringTransfer method that has a promise inside.

Only after transfers collection will be fully updated, I need to go another method that will do some work with this collection and it will be presented to template. It is like I need a wait till each call for recurring data will be completed before doing another call. It is not clear how many transfers are actually recurring. I just need a collection, fully loaded with recurring data, before I would do other processing. How I would do that with Ember? Thanks!

Posts: 6

Participants: 3

Read full topic

Viewing all 4841 articles
Browse latest View live


Latest Images