I have a "click" event assigned to a link. When the event fires, I'd 
like to unbind this event and re-assign a new "click" event to the link. 
The re-assignment is handled within the originating "click" event.

This works FINE in FF 1.5/+. It crashes IE by sending it in a continuous 
loop (IE seems to immediately execute the "click" event re-assignment, 
thus causing a recursive loop).

NOTE: I have tried using $.oneclick() to no avail.

Below is a short code synopsis. A demo page is posted @ 
http://dev.iceburg.net/jquery/tableEditor/rebind.html which demonstrates 
the issue using jQ plugin-format code.

---
<script>
$().ready(function() {   
   
    $("#link").click(function() {
        rebind(this,'a');
        return false;
    });
   
});

function rebind(link,action) {
        jQuery(link).html('link  '+action).unbind().click(function() {
            alert(action);
            rebind(link, (action == 'a') ? 'b' : 'a');
            // return false to halt browser link execution
            return false;   
        });   
}
</script>

<a href="#" id="link">Click Me!</a>
---

Is the a jQ bug? Is there a better workaround/means? I realize I could 
probably have 2 links & hide the inactive one.

Thanks,

~ Brice

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to