Teensweb
New Member
- Messages
- 352
- Reaction score
- 1
- Points
- 0
Alright, the problem I face now is simple and silly: I need to make some elements show up when another element is hovered, well this is simple, to understand where my problem arises, take a look at the below code:
Here, slideout() is a well defined custom function for a class of which el is a member.
Now, the problem is, the function builder is called everytime another parent and child system is built, so the el (which is a global variable) changes on each call of the function which means I lose the link between my previous parent and child. Is there any possible way to overcome this problem?
I guess(but I am not sure) that the problem can be solved if el is declared as a local variable of builder() but then, how would I access that variable inside the function(){} in the bind?
Code:
function builder(){
....
$(myelement).bind('mouseenter',function(){el.slideout()});
....
}
Now, the problem is, the function builder is called everytime another parent and child system is built, so the el (which is a global variable) changes on each call of the function which means I lose the link between my previous parent and child. Is there any possible way to overcome this problem?
I guess(but I am not sure) that the problem can be solved if el is declared as a local variable of builder() but then, how would I access that variable inside the function(){} in the bind?