Kan ikke få mit system til at skifte sprog korrekt.
Jeg sidder og forsøger at lave et script der skal opdatere indholdet i mine felter når man skifter mellem sprog. Problemet er bare at den konstant sletter sproget, kan simpelthen ikke finde en løsning på det og den melder ingen fejl. Er der nogen der kan hjælpe?[code]var content = new Array();
var old_lang;
$(document).ready(function()
{
console.log(old_lang = $('select[name=lang_selector]').val());
/*
* Load first language
*/
updateContent();
/*
* Change language
*/
$('select[name=lang_selector]').change(function()
{
updateContent();
});
/*
* Setup data and post the data
*/
$('#admin_add_page').submit(function()
{
console.log(content);
return false;
});
});
function updateContent()
{
// Save present value from tinymce editor
set_content($('textarea[data='+ old_lang +']').html());
// Hide inactive elements
$('.tinymce').css('display', 'none');
$('span[role=application]').css('display', 'none');
activeLang = $('select[name=lang_selector]').val();
$('textarea[data='+ activeLang +']').css('display', 'block');
get_content();
loadTinyMCE();
old_lang = $('select[name=lang_selector]').val();
}
function set_content(value)
{
console.log($('input[data=text_'+ old_lang +']').val(value));
}
function get_content()
{
activeLang = $('select[name=lang_selector]').val();
oldValue = $('input[data=text_'+ activeLang +']').val();
alert(oldValue);
$('textarea[data='+ activeLang +']').html(oldValue);
}
function loadTinyMCE()
{
// Activate tinymce
$('textarea.tinymce').tinymce({
// integrate tinymce handler
script_url: '<?php echo base_url('files/api/tinymce/jscripts/tiny_mce/tiny_mce.js'); ?>',
// plugins
plugins: 'insertdatetime, paste, autoresize, inlinepopups, Archiv, preview',
// Archiv settings
Archiv_settings_file : "<?php echo base_url('files/api/tinymce/jscripts/tiny_mce/plugins/Archiv/config.php'); ?>",
// general options
theme: 'advanced',
plugin_insertdate_dateFormat: '%d-%m-%Y',
plugin_insertdate_timeFormat: '%H:%M',
// setting up theme
theme_advanced_toolbar_location: 'top',
theme_advanced_toolbar_align: 'left',
theme_advanced_statusbar_location: 'bottom',
theme_advanced_resize_horizontal: false,
theme_advanced_resizing: true,
theme_advanced_resizing_min_height: 250,
// theme content
theme_advanced_buttons1: 'undo, redo, |, cut, paste, pasteword, fontselect, formatselect, fontsizeselect',
theme_advanced_buttons2: 'bold, italic, underline, |, justifyleft, justifycenter, justifyright, justifyfull, |, bullist, numlist, outdent, indent, blockquote, |, forecolor, backcolor, link, unlink, |, hr, charmap, |, insertdate, inserttime, |, Archiv_images, Archiv_files, | , code, preview',
theme_advanced_buttons3: '',
});
}[/code]