0
將數組傳遞給jQuery函數時遇到了問題。一些代碼:將codeigniter轉換數組傳遞給jQuery函數
// in the language file
$lang['daynames'] = array('So','Mo','Di','Mi','Do','Fr','Sa');
//In the view
<script type="text/javascript" charset="utf-8">
var config = { basePath : '<?php echo $base; ?>' }; // THIS WORKS GREAT!!!
var days = new array('<?php echo implode("','",$this->lang->line('daynames')); ?>');
</script>
//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){
}
});
});
如果我這樣做lang-> line('daynames'));在視圖中一切看起來都很好,所以這裏有什麼問題?
感謝和問候......
你檢查輸出,看它是否看起來有效? – 2010-05-27 08:27:57
我不知道爲什麼,Firebug說: 數組未定義 [Break on this error] var days = new array('So','Mo','Di','Mi','Do',' FR」, 'SA'); – fillibuster 2010-05-27 08:48:27
Damn:array!= Array – fillibuster 2010-05-27 08:52:13