Hi Everyone,
I’m completely new to Ember, but am building a chrome extension that builds features on top of an Ember app. What we keep struggling with is how to access anything from within their Ember scopes, add routes, etc. I figured the best place to start was to figure out how to access the Ember scope from the console without modifying the original source.
People have pasted initializer samples at me before, and they run, but I don’t know how to do anything with the Ember scope from there. How do I look up a view? A controller? How do I add a route? I’m happy to read docs, I just have nowhere to start.
The Ember Inspector can see the application, view tree, etc. How is it doing this? How do I access things from the console without modifying the original source? I started digging through their source but figured asking here would likely be a better approach.
They have both Em
and Ember
in the main scope, not sure why?
Anyone able to help at all?
This is an interesting question. When you say “access Ember scope from console,” what do you mean? Can you give a more specific example of what you’re trying to do?
No worries.
Our code comes from a browser extension. It’s not built into the Ember app as it normally would be. It’s injected onto an Ember application’s page via standard <script>
tags. We want to be able to do things like alter Ember templates.
So we’ve got access to window
, Ember
, and Em
objects. We have found some Ember Data objects floating around that we’re doing stuff with, but the reason I’m asking for this from the console is basically I’m saying, “From outside of where you’d normally write Ember code”.
One example is we’re trying to close a modal in the app. Our code currently looks like this:
return Ember.View.views[Ember.keys(Ember.View.views)[viewIndex]].container.lookup(containerName);
I’m not sure if this is our best option. How would we go about accessing an Ember view from the developer console in a browser on a running production built app that someone else builds and maintains?
Does that help?