简体   繁体   中英

jQuery 'on' event is different while using Ember JS

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

Could you please set false in EXTEND_PROTOTYPES in environment.js file. Please refer the below code snippets.You can achive this your output

var ENV = {
     ------
EmberENV: {
  FEATURES: {
    // Here you can enable experimental features on an ember canary build
    // e.g. 'with-controller': true
  },
  EXTEND_PROTOTYPES: false
}, 

This is not about jQuery's on function.

Ember has prototype extension feature. Ember extends function's, array's and string's prototype. The on is about function prototype extension. You can see the code from github repo .

You can also have a look at disabling prototype extensions from the guide.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM