Is jQuery automatically enabled for plugin components? Am I missing a setup step?
I am having issues with simply accessing the html DOM through jquery (with the end goal of jquery’s autocomplete function). Here is an example of one of my attempts, attempting to retrieve the ID of an element using its id. It never finds the element. Its as if the javascript does not have a reference point.
---- in /src/plugins/test/assets/javascripts/discourse/components ----
---- element-main.js.es6 ----
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import jQuery from 'jquery';
export default Ember.Component.extend({
init() {
this._super(...arguments);
console.log("in the templates/components/element-main.js.es6");
console.log(jQuery);
const aaa = jQuery('#eleinp');
console.log(aaa)
console.log(aaa.attr('id'));
}
});
---- in /src/plugins/test/assets/javascripts/discourse/templates/components ----
---- element-main.hbs ----
<p>element-main in temp</p>
<input id="eleinp" value="HAHAHA">
I tried this.element, $(this.element), $(this), $(), etc. as well.