I have this jQuery click event
$('#sidebar .nav a span').click(function () {
var sidebar_nav = $(this);
$("#main").load("type_change.php?id="+id, successCallback);
And then i have the callback to do the binding
var successCallback = function(responseText, textStatus, XMLHttpRequest) {
//doing all the binding in here
}
Is there a way to pass $(this) or sidebar_nav or to the successCallback function so I can do something with it
You could use
$.proxy:This will set
thisinsidesuccessCallbackto whatever you pass as second parameter.If you want
thisstill to refer to$("#main"), then you could change the callback to accept one more parameter:and call it like so:
targetwill refer tosidebar_nav.