We have https://github.com/RubaXa/Sortable working in our Lightning Components, however when we enable Locker Service we see an exception in Aura core code.

Uncaught TypeError: callback.call is not a function throws at https://win16f1l-dev-ed--sum16fw1.na30.visual.force.com/auraFW/javascript/h_soHR8Rt2_c3cVcuaSlUA/aura_proddebug.js:17830:20

It seems like the error happens when do

var obj = {
handleEvent: function() {
   dude: "holla"

element.addEventListener("click", obj, false);

Locker seems to have an issue calling the handleEvent method when you pass an object to the event listener.

Is this a known issue or is it explicitly blocked by Locker Service?

  • 1
    That is correct - currently Locker only supports the function datatype for the callback argument. This is the first time this has been reported, asked for, etc - do you have a support case opened on this or an idea on IdeaExchange? Feb 13, 2017 at 12:59

2 Answers 2


You should use the $A.getCallback(function callback) as it ensures that the framework rerenders the modified component and processes any enqueued actions

element.addEventListener("click", $A.getCallback(handleEventFunction), false);
  • $A.getCallback requires to me provide a function but if I want to pass the object and have JS call the handleEvent method automatically I cannot do that with $A.getCallback. The reason this is important is because we can pass the object and all of the references to the handleEvent method. Feb 12, 2017 at 18:16
  • can't you do something like that ? $A.getCallback(function(){ //do whatever you need with the variable obj })
    – Kevan
    Feb 12, 2017 at 18:30

@kevan, Thanks for the answer. I was able to do the following:

if (this.nativeDraggable) {
        var self = this;
        _on(el, 'dragover', $A.getCallback(function(e){
        _on(el, 'dragenter', $A.getCallback(function(e){

It seems like Locker Service does not allow the JS functionality that will auto call the handleEvent method when you pass an object as the callback. You have to use $A.getCallback and then create a manual event method to make sure everything is handled correctly.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .