Coder Social home page Coder Social logo

lautr / asfar Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 0.0 41 KB

a "simple" and unified approch to implement the new HTML5 History Interface & loading content via ajax

License: GNU General Public License v2.0

JavaScript 100.00%

asfar's People

Contributors

lautr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

asfar's Issues

Entire page is re-inserted within #content

I'm assuming I'm missing something, but in the basic implementation in a page with a #content div I do get an ajax reload, but I get the entire request page loaded in to the that div, not just the corresponding #content section. Is there an obvious reason why this would happen? I figured the idea was that if #content is the target it would also look for and load only that div from the request page.

Stop jQuery from cycling

I have arrows for pagination that link to the next/previous pages. However, because I am using Ajax, jQuery still cycles the slide effect even if there are no other pages to be viewed. Is there a way to stop that?

Additionally, if I have 3 pages worth of articles, the paginated arrows will only link to the first and last page. Is there a way to solve this? I tried putting them inside #ajax however, ajax kind of fails.

By the way, I had to create two pieces of code to get the slide effect to work.

Live example: http://chrisburton.me/dev

$('#ajax').asfar({
      selector : '.l-arrow',
    before : function(urlFragment,target){
        console.log('before');
    },
    insert : function(urlFragment,target,data){
        $(target).hide("slide", { direction: "right" }, 500, function(){
            $(target).html(data);
            $(target).show("slide", { direction: "left" }, 500);
        });
    },
    after : function(urlFragment,target){
        console.log('after');
    },
    success : function(urlFragment,target){
        if(0 > $('a[href="' + urlFragment + '"]').length){
            $('a').removeClass('active');
            $('a[href="' + urlFragment + '"]').addClass('active');
        }
        _gaq.push(['_trackPageview',urlFragment]);
    }
});


$('#ajax').asfar({
      selector : '.r-arrow',
    before : function(urlFragment,target){
        console.log('before');
    },
    insert : function(urlFragment,target,data){
        $(target).hide("slide", { direction: "left" }, 500, function(){
            $(target).html(data);
            $(target).show("slide", { direction: "right" }, 500);
        });
    },
    after : function(urlFragment,target){
        console.log('after');
    },
    success : function(urlFragment,target){
        if(0 > $('a[href="' + urlFragment + '"]').length){
            $('a').removeClass('active');
            $('a[href="' + urlFragment + '"]').addClass('active');
        }
        _gaq.push(['_trackPageview',urlFragment]);
    }
});

Does not apply 'active' class

For whatever reason when I go to different pages, it does not append a class of active to the menu link. It just highlights the link that you land on.

Note: I am using the default Kirby installation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.