tags:

views:

12

answers:

2

Hello,

I am working on script where I have code like this...

$(document).delegate(scroll.links,'click',function(){
            switchTo(getId(this.href))
            return false
        })

I want to convert it into .live I tried but couldnt get it right.

Can anybody show me ?

Thanks.

A: 

You can do it this way:

$('scroll.links').live('click', function(){
   switchTo(getId(this.href));
   return false;
});

However, it is important to know the difference between the two:

Sarfraz
Thanks But Its not working !
MANnDAaR
@MANnDAaR: *Not working*. Can you elaborate little more what happens? Any error message there?
Sarfraz
@Sarfraz My Mistake.. I wrote it wrong.. Now Its Working fine . Thank You so much.
MANnDAaR
@MANnDAaR: Welcome :)
Sarfraz
A: 

From reading the docs, I imagine it would be something like this:

$(scroll.links).live("click", function() {
    switchTo(getId(this.href))
    return false
})

Note: I have not tested this. I successfully use delegate() in some of my own code; the docs suggest that delegate() is actually more powerful and more flexible.

staticsan