1

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.

Community
  • 1
  • 1
phazei
  • 5,323
  • 5
  • 42
  • 46
  • Every click somehow seems to match your selector 'a.sort', can you give the link an id and test it directly on that? – Fabian Mar 24 '10 at 00:17
  • I changed it to $('#djsfhaskdfas').livequery(...). It still fires the event. It seems it doesn't even matter what selector I put in there. – phazei Mar 24 '10 at 00:22
  • This answer is now out-of-date. Curious readers should look at http://api.jquery.com/on instead of `.livequery`. – Blazemonger Nov 14 '12 at 14:13

3 Answers3

2

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.

phazei
  • 5,323
  • 5
  • 42
  • 46
0

Use the rel attribute:

$('a[rel*=sort]') 
.livequery('click', function(event) { 
    alert('test'); 
});
Vonder
  • 4,033
  • 15
  • 44
  • 61
0

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

Vonder
  • 4,033
  • 15
  • 44
  • 61