kritya
kritya

Reputation: 3362

jQuery .delegate() with a plugin?

I am using a plugin named : jkey.

Now i want to use the .deligate() with it.

The basic syntax of this plugin is :

$(document).jkey('a',function(){
    jkey.log('You pressed the a key.');
});

QUESTION How do i supply the arguments like in this i want to send the key value 'a' i tried to do this

$("#hmm").delegate(".mm","jkey","a",function() {
    $("#get").html("WOW");
});

but failed

Upvotes: 1

Views: 884

Answers (1)

Amin Eshaq
Amin Eshaq

Reputation: 4024

The #hmm needs to be present at the start and .mm is what is being bound. You also need to give it an event for example 'click'

$("#hmm").delegate(".mm","click",function() {
    $(this).jkey('a',function(){
        jkey.log('You pressed the a key.');
    });
});

The code above doesn't make much sense but it will listen for a click on an element with class of "mm" inside an existing element with an id of "hmm". Once click, it'll bind jkey to the .mm element.

Elaborate a bit on what you're trying to do and I can give a better example

Upvotes: 1

Related Questions