lautr / asfar Goto Github PK
View Code? Open in Web Editor NEWa "simple" and unified approch to implement the new HTML5 History Interface & loading content via ajax
License: GNU General Public License v2.0
a "simple" and unified approch to implement the new HTML5 History Interface & loading content via ajax
License: GNU General Public License v2.0
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.
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]);
}
});
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.