mardi 9 juin 2015

EmberJS Component With Graph

I have an emberjs component that I was hoping to use to generate Highcharts graphs with.

For example, I want to be able to do {{component-name xy_data=data}} and have a graph generate with that data.

Currently, my template for the component is simple, it looks like

<button {{action "confirm"}}>Click again to confirm</button>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
{{yield}}

When the user clicks confirm, I use a jQuery callback provided by Highcharts to generate the graph for the container. This is very hacky but I can't understand where I should put the logic for this jQuery callback.

For example, do I put it in the route for each route that uses this component? This seems tedious to the developer to remember to do this.

Is there a way that I can have a setup phase in the component.js file that changes based on the contents of the model being passed in? To, my understanding there is a setupController but this is not available to components.

Aucun commentaire:

Enregistrer un commentaire