Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 1.02 KB

jquery-ember-run.md

File metadata and controls

38 lines (25 loc) · 1.02 KB

ember/jquery-ember-run

💼 This rule is enabled in the ✅ recommended config.

Don’t use jQuery without the Ember Run Loop.

Using plain jQuery invokes actions outside of the Ember Run Loop. In order to have a control on all operations in Ember, it's good practice to trigger actions in a run loop (using one of the @ember/runloop functions).

Examples

Examples of incorrect code for this rule:

import $ from 'jquery';

$('#something-rendered-by-jquery-plugin').on('click', () => {
  this._handlerActionFromController();
});

Examples of correct code for this rule:

import $ from 'jquery';
import { bind } from '@ember/runloop';

$('#something-rendered-by-jquery-plugin').on(
  'click',
  bind(this, this._handlerActionFromController)
);

Related