I'm having some problems getting the last part of this click function to work. The language_name and flag_url cookies are setting correctly, and the page is also reloading, but the .html() is not being replaced (last function).
So maybe the order of events is wrong? Not sure.
$("a.flag").click(function() {
$.cookie("language_name", $(this).attr("title"),{ path: "/" });
$.cookie("flag_url", $(this).find("img").attr("src"),{ path: "/" });
var lang_prefix = $(this).attr("class").split(" ")[2];
var language_name = $.cookie("language_name");
var flag_url = $.cookie("flag_url");
var default_lang = "<?php echo get_option('googlelanguagetranslator_language'); ?>";
if (lang_prefix != default_lang) {
setTimeout(function(){
window.location.href = window.location.href.split("?")[0] + "?lang=" + lang_prefix;
}, 200);
} else {
window.location.href = window.location.href.split("?")[0];
}
$(function() {
$("div.selected").html( "<a class=\"notranslate nturl\" title=\"" + language_name + "\" onclick=\"return false;\" href=\"#\"><span class=\"flag\"><img class=\"flagimg flagselect\" src=\"" + flag_url + "\" alt=\"" + language_name + "\" height=\"16\" width=\"16\"></span>" + language_name + "</a>");
});
});