CodeIgniter Forums
Pass translation array to jQuery Function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Pass translation array to jQuery Function (/showthread.php?tid=30827)



Pass translation array to jQuery Function - El Forum - 05-27-2010

[eluser]grolle[/eluser]
Hi,

I've a problem by passing an array to a jQuery function. Some code:
Code:
// in the language file
$lang['daynames'] = array('So','Mo','Di','Mi','Do','Fr','Sa');

// the view
[removed]
    var config     = { basePath : '<?php echo $base; ?>' }; //THIS WORKS!!!
    var days       = new array('<?php echo implode("','",$this->lang->line('daynames')); ?>');
[removed]

//in the js-File
        $(function() {
                $("#datepicker").datepicker({
                    dateFormat  : 'dd.mm.yy',
                    showWeek    : true,
                    firstDay    : 1,
                    weekHeader  : 'KW',
                    dayNamesMin : days,
                    monthNames  : ['Januar','Februar','März','April',
                                   'Mai','Juni','Juli','August','September',
                                   'Oktober','November','Dezember'],
                    onSelect    : function(dateText,inst){
                                  }
                });
    });
If I do <?php echo implode("','",$this->lang->line('daynames')); ?> in the view everything looks fine, so what is wrong here?

Thanks and best regards ...


Pass translation array to jQuery Function - El Forum - 05-27-2010

[eluser]cahva[/eluser]
In JS its uppercased so array should be Array


Pass translation array to jQuery Function - El Forum - 05-27-2010

[eluser]grolle[/eluser]
That's it. Thanks a lot. Thats why I love Delphi ;-)