Search code examples
javascriptember.jsember-cli

uncaught typeerror undefined is not a function in ember-cli


ember-cli newbie here and i just wanna get a feedback on this and hopefully also solve it.

ive been having this issue on ember-cli when i try to use Hammer.js.. i am trying to make a scroll horizontal touch gesture using hammerjs and ember component. so far, ive got ember component set up and hammerjs install via "ember bower install hammerjs" command. i am also importing it using a standard non-amd asset as explained in its documentation.. on Managing Dependencies section.

this is what my code looks like http://screencast.com/t/piKEMKa9S

i am also using foundation-apps styling and classnames.. hopefully if i get this to work, i wanted to contribute to foundation-apps for emberjs.

and these are the errors ive been getting http://screencast.com/t/7lWMrUqwf8Y6

thanks.. any help, ideas, feedback would be much appreciated..


Solution

  • From what I see in the code, you are passing the ember component to the Hammer instance instead of the component's DOM element:

    new Hammer(self) instead of new Hammer(self.$()[0]).

    self.$() will get the DOM's element wrapped in a jQuery object, to get the real DOM element (what Hammer is expecting), you can do self.$()[0] which will get the first DOM element in the jQuery object.

    Not sure if this is causing the issue, but I think it might be.