jQuery 'on' event is different while using Ember JS


#1

While binding function to a html element using jQuery ‘on’, why callback function func having on attribute in Ember JS which is not available in JQuery.

jQuery Application:

$('body').append("<div id='div1'></div>")
var func = function(){alert("Ember")};
var bind = $("#div1").on("click",func);
"on" in func  // returns false

Ember Application

$('body').append("<div id='div1'></div>")
var func = function(){alert("Ember")};
var bind = $("#div1").on("click",func);
"on" in func // returns true

#2

Hi @sathishkumar_sekar, is there any particular reason you’re doing this in jQuery and not using something like a component? Using jQuery directly is pretty strongly discouraged in Ember. Occasionally there are circumstances where it’s unavoidable, but you’ll save yourself a lot of time and trouble by using Ember conventions vs trying to work around Ember with jQuery.