#6729 closed bug (duplicate)
function unbind() doesnot remove internal variables in function toggle()
Reported by: | Marco Antonio Avella | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.5 |
Component: | event | Version: | 1.4.2 |
Keywords: | toggle() unbind() | Cc: | |
Blocked by: | Blocking: |
Description
when i want to delete the listener for a function toogle() for example: (i use the next funcion for show and hidden a fixed menu in the bottom of the page)
_ begin
jQuery('.libreria_titulo').toggle( function () {
jQuery('a',jQuery(this)).stop().animate({'marginBottom':'-155px'},200);
jQuery('.libreria_holder').stop().animate({'marginBottom':'-155px'},200);
return false;
},
function () {
jQuery('a',jQuery(this)).stop().animate({'marginBottom':'-2px'},200);
jQuery('.libreria_holder').stop().animate({'marginBottom':'-2px'},200);
return false;
}
);
end
when i use the unbind funcion to delete the listener en toggle function, (i have to say that i have to delete the listener because i use other button either to show o hidden the fixed menu, but without using toggle) i erase the listener this way:
jQuery('.libreria_titulo').unbind();
this unbind function do not remove o delete the internal toogle variable that i supouse is been used for the cicle, because when i create another toogle function (new function after i unbind the last toggle) to the same selector the cicle begin when the last toogle function ended)
it is necesary to remove this internal variable because when i move my menu ( show o hidden position) from other source (diferente of manual toggle, for example a button in other part of the page that show up my fixed menu), and then i create another toggle function with the same selector, when i make manual click to execute the toggle this does not hidden (move down) until another (second) click i made, because the last toggle function ended in the hidden position so that when i made the first click (using the new toogle function) my menu try to show (when actually is in the show position because it was moved up previusly by the button ) and until the second click is made my menu hidden correctly and makes the toggle right
if the internal variable were erased the same way as the listener (with the unbind function) it were no mather where was the last toggle when i create a new toggle function with the same selector (for example id make a function that starts showing the menu with the firt click always), and then i just try to erase and create new toggle function after using the button (to show and/or hidden) and when the actual position of the menu were hidden.
Change History (3)
comment:1 Changed 13 years ago by
Component: | unfiled → event |
---|
comment:2 Changed 12 years ago by
Milestone: | 1.4.3 → 1.5 |
---|---|
Priority: | → low |
Resolution: | → duplicate |
Status: | new → closed |
I'm gonna go ahead and just set this as a dupe of #234 - since it's the best solution to the problem described here...
Relevant to the proposal for .untoggle() in #234.