Accessing elements after DOM fired.

Hi,

I am writing some code for the front end of my site. I'm forced to use AJAX as our page loading method. We use anchors as hooks to detect what page the user was on (not sure if that's needed).

I'm having some problems with a tags after the DOM is loaded. So if you click onto another page which is loaded from AJAX it doesn't take the _initPages(); route.

Now, I know what you are going to say, just run that function every time I detect a hash change. I don't want to do that.

What I'm asking is there any jQuery function that looks at the DOM on click instead of at the time of the function is ran. Errr, confusing.

Thanks,

Code:

Code:
__construct: function()
{             
           
            this._initPages();
           
            $(window).bind('hashchange', function()
            {
                   
                mySite._detectHash();
               
                if( mySite._hash )
                { 
                   
                    mySite._loadPage(mySite._hash); 
                   
                }             
                   
            });
           
            $(window).trigger("hashchange");
           
            this._init();     
           
        },
 
        _initPages: function()
        {
         
         
            $( 'a:not(.noAjax)' ).on( 'click', function( )
            {
         
                window.location = '/#!/' + $( this ).attr('href');
               
                return false;
               
            } );
           
        }
 
What's the full code? Because what you've displayed isn't the complete thing (to much missing for anyone to help debug it).

I've sent you over a PM, I'm trusting you with sensitive code. We have information in there that we don't want getting out to our competitors.
 
I've sent you over a PM, I'm trusting you with sensitive code. We have information in there that we don't want getting out to our competitors.
I can't be trusted :sneaky:

.
.
.
.
.
.
.

(I'm just joking.:p No worries.:) But I bet I made your heart skip a beat there for a moment.:X3: LOL)

It will take me a while to review the code.
 
I gave a quick look over and from what I can see.... Nicely done. (y)

I'm wondering if maybe the conflict lies else where (conflict with something outside your code) or maybe we're both (you and me) missing something here.

I'd suggest 2 names in who I believe you can trust help debug this issue further (you should get in contact with one of them)
I also suggest these two because from the code you gave me, its clear this is part of a larger project. And I'm kind of limited on the time it would take to review the whole (larger picture).

But from what I could see... The code looked clean to me and should be loading smoothly. So clearly we're both missing something.
 
I gave a quick look over and from what I can see.... Nicely done. (y)

I'm wondering if maybe the conflict lies else where (conflict with something outside your code) or maybe we're both (you and me) missing something here.

I'd suggest 2 names in who I believe you can trust help debug this issue further (you should get in contact with one of them)
I also suggest these two because from the code you gave me, its clear this is part of a larger project. And I'm kind of limited on the time it would take to review the whole (larger picture).


But from what I could see... The code looked clean to me and should be loading smoothly. So clearly we're both missing something.

If you are in direct contact with them could you point them in this direction (give them the code if you need). I'm fairly new around here.
 
Back
Top Bottom