Search code examples
ember.jsember-dataember-clifindbyember-addon

Ember addon. method findBy() is not a function


I'm building an Ember addon using an Ember app that I've already built, but I'm having an issue with the method .findBy().

Basically in the app .findBy() works for an array of Objects (ember.Array class), but if I try to use it in the addon I get:

selectorsData.findBy() is not a function(...)

I think that the Addon doesn't recognize that it is an ember.Array

Picture of the methods for the array of objects IN THE ADDON enter image description here

Picture of the methods for the array of objects IN THE EMBER APP

enter image description here


Solution

  • By default, Ember addons do not have array prototype extensions such as findBy enabled, so that in apps that chose not to use the feature can still use the addon.

    In order to use findBy, ensure that the array is created using new Em.A() or subsequently wrapped using new Em.A(selectorsData).