2011-08-26 24 views
0

我想在我的應用程序中添加一個日曆。下面的代碼沒有在codeigntier中工作,但是如果將它放到codeigniter之外的另一個文件夾中,它可以正常工作。你能否幫我找出問題所在? 預先感謝日期選取器不能在Codeigniter中工作

<html> 
<head> 
<link href="calendar/calendar.css" rel="stylesheet" type="text/css" /> 
<script language="javascript" src="calendar/calendar.js"></script> 
</head> 

<body> 

<?php 
//get class into the page 


require_once('tc_calendar.php'); 



    $myCalendar = new tc_calendar("date5", true, false); 
    $myCalendar->setIcon ("calendar/images/iconCalendar.gif"); 
    $myCalendar->setDate(date('d'), date('m'), date('Y')); 
    $myCalendar->setPath("calendar/"); 
    $myCalendar->setYearInterval(1971, 2035); 
    $myCalendar->dateAllow('1971-01-01', '2035-01-01'); 
    $myCalendar->setDateFormat('j F Y'); 
    //$myCalendar->setHeight(350);  
    //$myCalendar->autoSubmit(true, "form1"); 
    $myCalendar->setAlignment('left', 'bottom'); 
    $myCalendar->writeScript(); 
    ?> 

    </body> 


    </html> 
+0

你是如何在codeigniter中加載的?這是一個視圖還是一個純html文件? – ace

+0

如果我在純HTML文件中加載上面的代碼,它工作正常,但是當我將它加載到codeigniter中的視圖文件時,它不起作用。謝謝 –

+1

啊,你是在什麼地方放置你的純html文件,如果它位於codeigniter之外?我認爲它可能與codeigniter一旦加載爲視圖時未找到「calendar/calendar.js」和「calendar/calendar.css」有關。 – ace

回答

2

您的資產路徑可能已關閉。嘗試在撥打資產時使用base_url(),看看是否有幫助。你的JS和CSS文件就被加載這樣的:

<link href="<?php echo base_url(); ?>calendar/calendar.css" rel="stylesheet" type="text/css" /> 
<script language="javascript" src="<?php echo base_url(); ?>calendar/calendar.js"></script> 

base_url()將讓你的應用程序的根,所以如果日曆目錄不在根目錄然後相應地更新路徑。檢查生成的HTML並查看它是否實際加載資產。