Подтвердить что ты не робот

JQuery: $(this) против этого. $()

В Ember.js docs у них есть фрагмент кода jQuery со следующим синтаксисом:

this.$().button();

Этот сниппет только превращает this в объект jQuery, так что функция jQuery UI .button() может быть вызвана на нем?

Будет ли этот фрагмент идентичным?

$(this).button();
4b9b3361

Ответ 1

Исходный код объясняет это следующим образом:

/**
    Returns a jQuery object for this view element. If you pass in a selector
    string, this method will return a jQuery object, using the current element
    as its buffer.

    For example, calling `view.$('li')` will return a jQuery object containing
    all of the `li` elements inside the DOM element of this view.

    @param {String} [selector] a jQuery-compatible selector string
    @returns {Ember.CoreQuery} the CoreQuery object for the DOM node
  */
  $: function(sel) {
    return this.invokeForState('$', sel);
  },

Итак, чтобы ответить на ваш вопрос: нет, это не то же самое, что $(this), который бы обернул экземпляр экземпляра ember в объект jQuery...