0
var rF = function(callback) {
    alert("there2222");
    //additional calls
    $(document).trigger("lc", [callback]);
};
var pSl = function(callback) {
    var func = pSR; // how to pass callback parameter in function
    rF(func);
};
var pSR = function(callback, vars) {
    alert(callback);
    alert(vars);
};

$(document).on("lc", function(e, callback) {
    alert("theaaa");
    alert(callback, "ssss");

});

$('img').click(function() {
    pSl("lol");
});
tmarwen
  • 15,750
  • 5
  • 43
  • 62
Kunal Vashist
  • 2,380
  • 6
  • 30
  • 59

1 Answers1

2

I guess you want to pass along callback to pSR. In that case you can use .bind:

var func = pSR.bind(null, callback);

or you put the call in another function:

rF(function() {
    pSR(callback);
});

However, the choice of the parameter name is questionable, since you seem to pass a string (not a function).

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143