# How to access current post tags using Ember and JavaScript?

**URL:** <https://meta.discourse.org/t/how-to-access-current-post-tags-using-ember-and-javascript/53354>\
**Category:** Development\
**Created:** [Novembre 25, 2016, 4:06 UTC](https://meta.discourse.org/t/how-to-access-current-post-tags-using-ember-and-javascript/53354 "2016-11-25T04:06:55Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Jay\_Crossler](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jay_crossler/32/121395_2.png) [@Jay\_Crossler](https://meta.discourse.org/u/Jay_Crossler)\
**Post date:** [Novembre 25, 2016, 4:06 UTC](https://meta.discourse.org/t/how-to-access-current-post-tags-using-ember-and-javascript/53354/1 "2016-11-25T04:06:55Z")

</div>

Hi, first time poster. Loving Discourse so far!

I’m writing a plugin that will do some auto-tagging suggesting based on the content of the title and post. I’m trying to access a few things at the JavaScript level - trying to get access to the client-side view of the current post that’s being typed in. My goal is to make a new route and action (similar to draft.json that gets sent every few letters typed), and have that respond with suggested tags if the server algorithm triggers a response. This of course needs tagging turned on in the admin menu.

I’m trying to access the Tag Chooser - I can do so in JQuery via: `$('input.tag-chooser')`

But, if I try to add an existing tag programmatically, using:  
`$('input.tag-chooser').select2('data',{id:'tags', text:'tags'});`  
It then shows up on the UI, but not once I save it (guessing it didn’t save to the model) because I didn’t run `this.set('tags', tags);` – because I don’t have access to the `this` object. When I modify tag-chooser to get access, setting also doesn’t seem to work as expected.

But, I’m trying to get access to the main JS object that is built in tag-chooser.js (in \_initValue) so that I can add a tag to it… or maybe to access the Ember object to add a tag that way. I see that it looks like the main Global variables are in the JS Discourse object… but I’m not sure how to do something like Discourse.get(‘Tags’) or Discourse.set(‘Tags’) or what.

Any suggestions on where to start? I’m going through Ember tutorials now, but it’s a bit slow going.

---

_[View the full topic](https://meta.discourse.org/t/how-to-access-current-post-tags-using-ember-and-javascript/53354)._
