rap-2-h
rap-2-h

Reputation: 31978

Replace deprecated `this.$()` in Ember 3

this.$() has been deprecated in Ember.js and will be removed in Ember 4. It should be replaced with native Javascript. Still, the migration could be hard to do in one shot.

Is this the right way to replace previous this.$() while continuing using JQuery?

// BEFORE
this.$().on('transitionend', () => this.doSomething());

// AFTER
import $ from 'jquery';

$(this.element).on('transitionend', () => this.doSomething());

Or is there another approach?

Upvotes: 1

Views: 418

Answers (1)

jelhan
jelhan

Reputation: 6338

Yes. This would be a valid step even so it's a very small one. I would recommend that you try to replace jQuery with native JavaScript at least for the easy targets. There is even a codemod to help you doing so:

npx ember-3x-codemods jquery-apis path/of/files/

Please find more Infos in it's documentation.

Upvotes: 4

Related Questions