mardi 13 juin 2017

Dynamic linkTo with a plain anchor tag in Ember.js

export default Ember.Component.extend({
  tagName: '',

  actions: {
    checkUrl(post) {
      if(!Ember.get(post, 'property')) {
        event.preventDefault();
        // show modal dialog
      }
    }
  }
});

<a href="" >URL</a>

The above component with generate a link to open 'otherUrl'. if the post object doesn't contain 'otherUrl' i will a show a modal dialog

Dialog Template (Different Component)

<p>No Link Found. Go to <a class="post-link">post</a> and add otherUrl</p>

I want to point the 'post-link' anchor tag to different 'post' route each time like 'post/1', 'post/2' etc basing the post user clicked in the first place. Should i recompile or rerender modal dialog template for this. One way to do this manipulate DOM and add href for that 'post-link' basing post user click. But the resultant link will trigger the full page load instead of route. Could someone guide me on how to achieve this




Aucun commentaire:

Enregistrer un commentaire