views:

85

answers:

2

Hi, I made a jQuery loader for my content div. However it doesn't display my div class="typeface" anymore. This means I can't use different fonts. The rest of the content div works properly. Can anyone help me?

Javascript code: (for elements)

$(document).ready(function() {  

    // Check for hash value in URL  
    var hash = window.location.hash.substr(1);  
    var href = $('#nav li a').each(function(){  
        var href = $(this).attr('href');  
        if(hash==href.substr(0,href.length-5)){  
            var toLoad = hash+'.html #content';  
            $('#content').load(toLoad)  
        }  
    });  

    $('#nav li a').click(function(){  

      var toLoad = $(this).attr('href')+' #content';  
      $('#content').hide('fast',loadContent);  
      $('#load').remove();  
      $('#wrapper').append('<span id="load">LOADING...</span>');  
      $('#load').fadeIn('normal');  
      window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);  
      function loadContent() {  
       $('#content').load(toLoad,'',showNewContent())  
      }  
      function showNewContent() {  
       $('#content').show('normal',hideLoader());  
      }  
      function hideLoader() {  
       $('#load').fadeOut('normal');  
      }  
      return false;  

    });  
});  

HTML code:

<body> 
<div id="wrapper"> 
    <ul id="nav">
       <li><a href="index.html">welcome</a></li>
    </ul>
      <div id="content">

      <div class="typeface-js" style="font-family: Helvetiker; color:#0182a8;  font-size:25px; margin-bottom:10px;">Mauris ac eros. Donec quis lacus Header text.
      </div>

      Morbi gravida posuere est. Fusce id augue. More content text.

      </div>

</div>
A: 

You're loading something completely over the '#content' div, so of course the "typeface-js" div is going to go away (unless what you load it with also has that in it). Do you see? When you call

$('#content').load( ... )

then whatever was in that <div> before will be gone.

Pointy
A: 

.load will clear the entire contents of the target container element (ie: "#content")

<div id="content"> .... cleared ..... </div>

since your "typeface-js" element is contained in the content div, it is being cleared when your load completes.

Chris R