phazei
phazei

Reputation: 5437

jquery livequery event triggered on EVERYTHING, not just selected element

I am attempting to use livequery. I unfortunately am stuck using jquery 1.2.6.

This is my code:

$(document).ready(function() {
    $('a.sort').livequery('click', function(event) {
        alert('hello');
    });
});

If I click ANYWHERE in the document, I get the alert 'hello'.

What exactly is wrong there? Is it some bug with jQ1.2.6 and livequery 1.1.1?

This same question was asked here but the question wasn't clear, and the answer didn't help.

Upvotes: 1

Views: 1714

Answers (3)

phazei
phazei

Reputation: 5437

Shucks...

livequery 1.1.1 is NOT compatible with jQuery 1.2.6. It only works with jQuery 1.3+

If you need to use a version < 1.3, then livequery 1.0.3 is the latest one that can be used.

Upvotes: 2

Vonder
Vonder

Reputation: 4059

Get rid of this: $(document).ready(function() { It is triggered for whole document, rather than requested element.

Upvotes: 0

Vonder
Vonder

Reputation: 4059

Use the rel attribute:

$('a[rel*=sort]') 
.livequery('click', function(event) { 
    alert('test'); 
});

Upvotes: 0

Related Questions