Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinitialize or Remove djax? #21

Open
mattfordham opened this issue Jan 26, 2013 · 5 comments
Open

Reinitialize or Remove djax? #21

mattfordham opened this issue Jan 26, 2013 · 5 comments

Comments

@mattfordham
Copy link

I am loading some content in via AJAX (not using djax). This content contains links that I'd like to have djax do its thing with. Is there are way to reinitialize or remove/add-back djax? If I just call the djax method a second time, all the events fire twice. Any ideas?

@beezee
Copy link
Owner

beezee commented Feb 10, 2013

There's actually a small adjustment to the initialization code required to allow this to work simply, but will require some testing. I'll do my best to get to this shortly, but if you have time and interest, lines 197 to 201 would become something closer to this:

$(this).find('a').filter(function () {
        return this.hostname === location.hostname;
}).addClass('dJAX_internal')

$(this).on('click', '.dJAX_internal', function (event) {
        if (this.hostname !== location.hostname)
            return;
        event.preventDefault();
        return self.attachClick(this, event);
});

That should use delegated events to trigger djax nav on links with the dJAX_internal class, which means you can add that class to your links loaded in via ajax (not djax) and djax should pick them up. The extra conditional check to ensure the link is internal will prevent a mis-assigned class from breaking an external link.

Let me know if you get a chance to try this out, otherwise I'll update this thread when I get a chance to dig into it myself.

@AdamWagner
Copy link

Dealing with the same scenario.
I changed the lines you suggested. Functions as desired so far! More testing needed.
Thanks for posting the adjustment.

@beezee
Copy link
Owner

beezee commented Feb 25, 2013

Glad to hear Adam and thanks for the update. Let me know if you run into any issues with this otherwise I'll try and get it into the master branch in the next few weeks

@beezee
Copy link
Owner

beezee commented Jun 16, 2013

@AdamWagner do you have your changed copy up on Github? If so would be happy to merge a pull request

@AdamWagner
Copy link

No, but I'll branch + apply changes, then pull.

Adam Wagner
Copilot

On Sunday, June 16, 2013 at 7:44 AM, beezee wrote:

@AdamWagner (https://github.com/AdamWagner) do you have your changed copy up on Github? If so would be happy to merge a pull request


Reply to this email directly or view it on GitHub (#21 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants