Search code examples
ember.jsember-cliember-router

Updating permalink-property of object also updates URL in browser?


I've created an editor for my posts using this URL scheme

http://localhost:4200/admin/edit-post/post-permalink

You can change post-permalink via ember's input-helper.

{{input type="text" value=permalink}}

How can I at the same time alter the URL in the browser to reflect the altered permalink?


Solution

  • Thanks to the comment of @andrusieczko I was able to solve this problem myself by reading the documentation http://emberjs.com/guides/routing/query-params/ :)

    import Ember from 'ember';
    export default Ember.ObjectController.extend({
    
    permalinkChanged: function() {
       this.transitionToRoute("/admin/posts/edit/" + this.get('permalink'))
    }.observes('permalink')
    

    Note: I used an observer to the value instead of an action-helper because key-press changes the value after triggering the action.