Note that there are some explanatory texts on larger screens.

plurals
  1. PODetect URL change and grab URL in EmberJS (using Discourse)
    primarykey
    data
    text
    <p>I'm using Discourse (<a href="http://www.discourse.org/" rel="nofollow noreferrer">http://www.discourse.org/</a>), which is built on EmberJS, and trying to observe any time the URL changes, e.g. when opening a new topic. I've seen the answer for observing the currentPath, for example here: <a href="https://stackoverflow.com/questions/14425276/detect-route-transitions-in-emberjs-1-0-0-pre-4">Detect route transitions in EmberJS 1.0.0-pre.4</a></p> <pre><code>App.ApplicationController = Ember.Controller.extend({ routeChanged: function(){ // the currentPath has changed; }.observes('currentPath'); }); </code></pre> <p>But I'm trying to detect <em>any</em> URL change, not just a path change. As mentioned in the comments for that answer:</p> <blockquote> <p>This observer doesn't fire when transitioning from for example <code>/pages/1</code> to <code>/pages/2</code> because the path is staying the same: <code>pages.page.index</code></p> </blockquote> <p>What I'd like to do is actually detect those aforementioned transitions which don't get triggered by <code>observes('currentPath')</code>. Along those lines, if I do <code>this.get('currentPath');</code> inside of my function, I get something like <code>topic.fromParams</code> but I actually am interested in the URL path e.g. <code>/t/this-is-my-url-slug</code>. </p> <p>To put it simply, I'd like to detect when the app goes from:</p> <pre><code>/t/this-is-my-url-slug </code></pre> <p>to</p> <pre><code>/t/another-url-slug </code></pre> <p><em>and</em> be able to capture the path: <code>/t/another-url-slug</code></p> <p>Sorry but I'm a bit of an Ember n00b and my only experience with it is through Discourse. Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload