Question

I am Using YUI3 and having difficulty to find the problem?

Here i have this

YUI().use("modules",function(Y){  
    function Actionfunction(e){  
        //doing some stuff  
    }  
    Y.delegate("click",Actionfunction, "body","#myid li");  
});

And when i click on li items Actionfunction execute once but on second click on same li item or other li item Actionfunction execute twice and so on.

Actionfunction should execute only once on every click on li item.

Était-ce utile?

La solution 3

Got an answer here is the problem

showed the problem zone by commenting in front of syntax.

Q. What was the problem?
A. On every call of contextmenu, Y.delegate redefine because of that execution increases on click on li item

Autres conseils

I suspect the delegate subscription is happening twice. I'd drop a breakpoint in the code that's adding the subscription and see if it's getting called in response to some other action, or in response to the first click.

I would load the Event module specifically for this example. I would also refer to Y.Event.delegate().

This (jsfiddle example) works and is easier to read and understand.

I am afraid I cannot explain why your example failed since I cannot reproduce it.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top