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
  • 14,219
  • 4
  • 40
  • 59
Kunal Vashist
  • 2,286
  • 6
  • 26
  • 56

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
  • 756,363
  • 169
  • 1,062
  • 1,111