I seem to have problem with jQuery bind() and unbind() functions. They seem to not get executed at all. Here’s the code I have so far:
$(function() {
var init = function() {
$.get('test.php', function(j) {
if(j.r && j.r == 'error') {
console.log("1");
$('#far').bind('click', function() {
console.log("2"); return false;
});
} else {
//getData();
}
})
}();
var getData = function() {
$('#far').unbind('click', false);
};
$('#far').click(function() { ... });
});
Console only shows me 1 and no errors. I have no idea what I’m doing wrong since there are no errors and jQuery docs and StackOverflow has given me the same answer. I’m using jQuery 1.4.4
What am I doing wrong?
As I see you’re binding event before it’s created, so use
liveinstead.