Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript #85: Best Practices with Dynamic Content problem

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #31726
    XaviJr
    Participant

    Hi there!
    I’m having a problem with this tutorial (https://css-tricks.com/video-screencasts/85-best-practices-dynamic-content/).

    I have this js code:

    $(function() {

    var newHash = "",
    $rightCol = $("#right-col");

    $("#menu").delegate("a", "click", function() {

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

    return false;
    });

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

    newHash = window.location.hash;

    $rightCol.load(newHash);
    });

    });

    And it’s giving me this error:
    uncaught exception: [Exception… “Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]” nsresult: “0x80070057 (NS_ERROR_ILLEGAL_VALUE)” location: “JS frame :: http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js :: anonymous :: line 138” data: no]

    It’s strange because i’m using the library files included in this tutorial.

    Another thing strange is that it’s working if i change the code to:

    $(function() {

    var newHash = "",
    $rightCol = $(right-col);

    $("#menu").delegate("a", "click", function() {

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

    return false;
    });

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

    newHash = window.location.hash;

    $rightCol.load(newHash);
    });

    });

    The only thing is that obvious gives me the error “right is not defined”.

    Can anyone help me please? Thank you.

    #58879
    XaviJr
    Participant

    Ok, i’ve corrected that and have this working.

    Now i have another problem. I’m using Cuffon fonts on my dynamic content, so when i load the new content to #guts it simply disable all this fonts. I’ve tried to do this:

    $rightCol.load(newHash + ” #guts”);
    Cufon.refresh();

    But it’s the same. Any solution?

    #58872
    rickylamerz
    Member

    XaviJr you could try:


    $rightCol.load(newHash + " #guts",function(){
    Cufon.refresh();
    });

    Then it will execute after the load is complete.

    #58766
    XaviJr
    Participant

    yes, that worked, thanks!

    now i have a final problem.. special characters like á or ã are disappearing and i think it’s the encoding. they only appear with cufon when i save my php files with ANSI encoding, UTF-8 makes appearing other characters. but i think this load function uses UTF-8. Is there a way to change it to ANSI too?

    #58777
    XaviJr
    Participant

    Well, i made it work. I saved my php files with UTF-8. If i load cufon just one time when i enter the website it scramble special characters, but when i add $(window).trigger(“hashchange”); and he loads twice all appears nice.

    Once again thanks for the help ricky.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.