...

View Full Version : jQuery simple fade effect problem!?



freshUser
10-07-2010, 01:55 AM
Hi,
this is my first jQuery try - I tried a simple content fade in fade out effect for my Joomla Template.

heres some code:



$(function() {

var newHash = "",
$mainContent = $("#main-content"),
$pageWrap = $("#wrapper"),
baseHeight = 0,
$el;

$pageWrap.height($pageWrap.height());
baseHeight = $pageWrap.height() - $mainContent.height();

$("nav").delegate("a", "click", function() {

window.location.hash = $(this).attr("href");


return false;
});

$(window).bind('hashchange', function(){

newHash = window.location.hash.substring(1);

if (newHash) {
$mainContent
.find("#guts")
.fadeOut(200, function() {
$mainContent.hide().load(newHash + " #guts", function() {
$mainContent.fadeIn(200, function() {
$pageWrap.animate({
height: baseHeight + $mainContent.height() + "px"
});
});
$("nav a").removeClass("current");
$("nav a[href="+newHash+"]").addClass("current");

});
});
};

});

$(window).trigger('hashchange');

});







the script works but the problem is that after I click in my navigation I get a link like:

mypage.com/workspace/joomla/#/workspace/joomla/news

And I want:
mypage.com/workspace/joomla/news

so I tried to change the window location to:
window.location.hash = $(this).attr('href').substr(0,$(this).lastIndexOf('/') + 1);

that works but - now the effect don't work!?? :confused:

hope someone can help me out with that - thanks!

DreamCrafter
10-07-2010, 02:03 AM
Change back to what you originally had to start off with, the one where you didn't want it to link. Now create a php file named index. Place this coding in the file:


<?php
Header ( 'Location:http://mypage.com/workspace/joomla/news/' );
?>

Probably the most simplest way since you haven't posted all the coding.

freshUser
10-07-2010, 03:05 AM
Hi,
thanks but that don't really helps because - everything works, it's not linked to the wrong address - the js just creates the wrong url in the browser. If I move back to the start page - I get this url:

mypage.com/workspace/joomla/#http://mypage.com/workspace/joomla/



so - if I use this:



window.location.hash = $(this).attr('href').substr(0,$(this).lastIndexOf('/') + 1);


the urls are like how I want them - but then the jquery effect don't works - !?

any other ideas??

thanks

freshUser
10-07-2010, 03:30 PM
..can't find my mistake - if someone has an idea that would be nice.. thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum