Ember.js: Cannot remove jQuery deprecation error in Ember 3.9.0

Created on 12 Apr 2019  ·  3Comments  ·  Source: emberjs/ember.js

The deprecation warning says:

Using Ember.$() has been deprecated, useimport jQuery from 'jquery';instead [deprecation id: ember-views.curly-components.jquery-element] See https://emberjs.com/deprecations/v3.x#toc_jquery-apis for more details.

My code in question is as following

import jQuery from 'jquery';

import Component from '@ember/component';
export default Component.extend({
  ...
    _addResizableHandlers() {
        const jqueryElement = jQuery(this.element);
        jqueryElement.resizable({
            handles: 'all',
            stop: bind(this, this._onResizeEnd)
        });
        this._resizableInstance = jqueryElement.resizable('instance');
    },
  ...
});

that method is getting transpiled to

_addResizableHandlers() {
      const jqueryElement = Ember.$(this.element);
      jqueryElement.resizable({
        handles: 'all',
        stop: Ember.run.bind(this, this._onResizeEnd)
      });
      this._resizableInstance = jqueryElement.resizable('instance');
    },

package.json

"@ember/jquery": "^0.5.2",

I believe that because I believe that because my yarn.lock was pointing to 0.5.2, it wasn't transpliing properly.

By upgrading to 0.6.0, the deprecation warning went away, but I believe @ember/jquery should be ^0.6.0 for the default blueprint in 3.9.0

Most helpful comment

I have a simular problem: I have created a new ember project with ember new .
ember-cli version is 3.9.0. Changing into the new project folder and call 'ember test' it works without errors.
But if i generate e.g. a new model with 'ember g model test1' and then call 'ember test' i get the following warnings:
WARN: DEPRECATION: Using Ember.$() has been deprecated, use import jQuery from 'jquery'; instead [deprecation id: ember-views.curly-components.jquery-element] See https://emberjs.com/deprecations/v3.x#toc_jquery-apis for more details.
for 6 times.
Any idea? Greetings

All 3 comments

I believe @ember/jquery should be ^0.6.0 for the default blueprint in 3.9.0

Yep, agreed. Would you mind reporting over in ember-cli/ember-cli?

I have a simular problem: I have created a new ember project with ember new .
ember-cli version is 3.9.0. Changing into the new project folder and call 'ember test' it works without errors.
But if i generate e.g. a new model with 'ember g model test1' and then call 'ember test' i get the following warnings:
WARN: DEPRECATION: Using Ember.$() has been deprecated, use import jQuery from 'jquery'; instead [deprecation id: ember-views.curly-components.jquery-element] See https://emberjs.com/deprecations/v3.x#toc_jquery-apis for more details.
for 6 times.
Any idea? Greetings

FWIW, the reported issue has been resolved (was released in a patch version of 3.9, and is also included in 3.10 which was just released). I'm going to close this for now...

Was this page helpful?
0 / 5 - 0 ratings