I was doing something similar recently. I'm not sure if this is the
best/right way to do it, but I just added an "unbind" at the start of
the function (before the click event handler is applied) to prevent
bubling.

e.g.

function foo(){

        $('a').unbind( "click" );

        $('a').click(function(){
                         $.get("test.html", function(data){
                                $('#divId').append(data);
                                foo();
                        });
        });

}

On May 5, 4:13 am, summea <[EMAIL PROTECTED]> wrote:
> I've been asking about the same problem (and still searching (in
> vain?) for an answer to the question here on the jQuery group...).
>
> I have a click function that I bind to each folder link in an
> imaginary file manager script.  The problem is still, when I click on
> one folder and it displays its contents, the click function keeps
> going and opens and closed the folder when it should STOP after being
> clicked once.  And it should attach its click function (in an
> UNCLICKED state,) to the just-clicked folder's children folders...
>
> I've been reading up on events bubbling and stopping propagation,
> returning false, etc.  But nothing seems to be working.  I've tried
> adding a parameter even to the bindFolderAction function to check if
> it's been clicked or not.  But when I tried that, the children
> folder's wouldn't have bindFolderAction binded to them, and that's
> what I need to do as well.
>
> Here is the function I have so far, I've tried it another way since I
> last posted... and still have had no suggestions... or replies on the
> other post.  Any help?
>
> bindFolderAction = function(){
>
>         $('.myTree').find('a').bind('click', function(evt){
>
>                 evt.stopPropagation();
>                 evt.preventDefault();
>
>                 alert('this is not stopping...');
>
>                 var linkval = $(this).attr('href');
>
>                 subbranch = $('ul', this.parentNode).eq(0);
>                 $.log(subbranch.css('display'));
>
>                 $.log(this.firstChild);
>
>                 if (subbranch.css('display') == 'none') {
>
>                         //$.log('OPENED');
>                         subbranch.show();
>                         this.firstChild.src = '../img/open.gif';
>
>                         $
> (this.parentNode.getElementsByTagName('ul')).load(linkval, function()
> {
>
>                         bindFolderAction();
>                         return false;
>                         });
>
>                 } else {
>
>                         //$.log('CLOSED');
>                         subbranch.hide();
>
>                         this.firstChild.src = '../img/closed.gif';
>
>                 }
>
>                 return false;
>         });
>
> }

Reply via email to