Home › Forums › JavaScript › #85: Best Practices with Dynamic Content problem
- This topic is empty.
-
AuthorPosts
-
February 22, 2011 at 6:03 am #31726
XaviJr
ParticipantHi 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.
February 22, 2011 at 12:24 pm #58879XaviJr
ParticipantOk, 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?
February 22, 2011 at 3:49 pm #58872rickylamerz
MemberXaviJr you could try:
$rightCol.load(newHash + " #guts",function(){
Cufon.refresh();
});
Then it will execute after the load is complete.
February 23, 2011 at 7:23 am #58766XaviJr
Participantyes, 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?
February 23, 2011 at 10:20 am #58777XaviJr
ParticipantWell, 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.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.