2013-09-26 35 views
0

工作,我將一個PHP項目進入CakePHP的,並具有與預先定義的jQuery腳本像日期選擇器,文本編輯器等問題jQuery的腳本不CakePHP中

這裏是我的CSS,而在頁面上添加腳本: (如果你右擊頁面,然後點擊頁面的源代碼)

<link rel="stylesheet" type="text/css" href="/cakeskite/css/common.css" /> 
<link rel="stylesheet" type="text/css" href="/cakeskite/css/creatorcommon.css" /> 
<link rel="stylesheet" type="text/css" href="/cakeskite/css/jquery-ui.css" /> 
<link rel="stylesheet" type="text/css" href="/cakeskite/css/cssbuttons.css" /> 
<link rel="stylesheet" type="text/css" href="/cakeskite/css/jquery-te-1.4.0.css" /> 
<link rel="stylesheet" type="text/css" href="/cakeskite/css/jquery.datepick.css" /> 

<script type="text/javascript" src="/cakeskite/js/jquery.js"></script> 
<script type="text/javascript" src="/cakeskite/js/jquery-ui-1.8.2.custom.min.js"></script> 
<script type="text/javascript" src="/cakeskite/js/jquery.simplemodal.js"></script> 
<script type="text/javascript" src="/cakeskite/js/jquery.datepick.js"></script> 
<script type="text/javascript" src="/cakeskite/js/jquery.ptTimeSelect.js"></script> 
<script type="text/javascript" src="/cakeskite/js/jquery-te-1.4.0.js"></script> 
<script type="text/javascript" src="/cakeskite/js/common.js"></script> 
<script type="text/javascript" src="/cakeskite/js/creatorcommon.js"></script> 

如果我點擊任何鏈接,它顯示該文件存在,所以它不是文件中沒有發現問題。我可以檢查,在鉻控制檯太

我說我的劇本在這樣的佈局文件:

<?php 
echo $this->Html->css('common'); 
echo $this->Html->css('creatorcommon'); 
echo $this->Html->css('jquery-ui'); 
echo $this->Html->css('cssbuttons'); 
echo $this->Html->css('jquery-te-1.4.0'); 
echo $this->Html->css('jquery.datepick'); 

echo $this->Html->script('jquery'); 
echo $this->Html->script('jquery-ui-1.8.2.custom.min'); 
echo $this->Html->script('jquery.simplemodal'); 
echo $this->Html->script('jquery.datepick'); 
echo $this->Html->script('jquery.ptTimeSelect'); 
echo $this->Html->script('jquery-te-1.4.0'); 
echo $this->Html->script('common'); 
echo $this->Html->script('creatorcommon'); 

echo $scripts_for_layout; 
?> 

我把我所有的CSS和腳本文件的根目錄/ JS & Webroot公司/ CSS文件夾

我得到的錯誤如:

Object [object Object] has no method 'datepick' 

而他們正在非cakephp項目中工作。下面是HTML和腳本行的文件

注:我使用Ajax來加載的東西,我綁定控件時,我接收到的數據

$.ajax({ 
    url: 'loadtests', 
    type: 'POST', 
    data: 'category_id=' + category_id + '&subcategory_id=' + subcategory_id, 
    success: function(result){ 

     stopLoading(); 
     if(!isSessionExpired(result)){ 

      $(".msg").html("&nbsp;"); 

      if(result.indexOf("No tests found...")>-1){ 
       $(".tests").html("No tests found..."); 
      } 
      else{ 
       $(".tests").html(result); 

       $(".testfound").css("display","block"); 
       $(".durationrow").css("display","block"); 
       $(".noduration").css("display","none");    

       disableKeyPress($("input[name='startdate']")); 
       disableKeyPress($("input[name='enddate']")); 
       disableKeyPress($("input[name='starttime']")); 
       disableKeyPress($("input[name='endtime']")); 

       $("input[name='startdate']").datepick({dateFormat: 'yyyy-mm-dd', changeMonth: false}); 
       $("input[name='enddate']").datepick({dateFormat: 'yyyy-mm-dd', changeMonth: false}); 
       $("input[name='starttime']").ptTimeSelect(); 
       $("input[name='endtime']").ptTimeSelect(); 

       $(".datepicker").css("display","block"); 
       $("select[name='test']").change(
         function(){ 
          checkTestDuration(); 
         } 
        ); 

       checkTestDuration(); 
      } 
     } 
     else 
      notLoggedIn(); 
    } 

這裏是我的HTML表單:

<div class="createrow timebound testfound"> 
     <div class="column150 leftfloat">Start Date</div> 
     <div class="column250 leftfloat"> 
      <input name="startdate" class="txt100" /> 
     </div> 
     <div class="column150 leftfloat msg">&nbsp;</div> 
     <div class="clear"></div> 
    </div> 

    <div class="createrow timebound testfound"> 
     <div class="column150 leftfloat">End Date</div> 
     <div class="column250 leftfloat"> 
      <input name="enddate" class="txt100" /> 
     </div> 
     <div class="column150 leftfloat msg">&nbsp;</div> 
     <div class="clear"></div> 
    </div> 

    <div class="createrow timebound testfound"> 
     <div class="column150 leftfloat">Start Time</div> 
     <div class="column250 leftfloat"> 
      <input name="starttime" class="txt100" /> 
     </div> 
     <div class="column150 leftfloat msg">&nbsp;</div> 
     <div class="clear"></div> 
    </div> 

    <div class="createrow timebound testfound"> 
     <div class="column150 leftfloat">End Time</div> 
     <div class="column250 leftfloat"> 
      <input name="endtime" class="txt100" /> 
     </div> 
     <div class="column150 leftfloat msg">&nbsp;</div> 
     <div class="clear"></div> 
    </div> 

我在做什麼錯?

+0

入住'jquery.datepick'定義什麼方法。 –

+0

@Arun,相同的代碼在基於非cakephp的項目中工作 此外,沒有任何外部腳本像datepicker,timepicker,文本編輯器等工作 – Ashutosh

+0

什麼觸發jQuery腳本? –

回答

0

我努力尋找解決方案,我走近90%

我創建使用CakePHP另一個項目和使用的唯一的一次選擇,並且工作得很好

因此,我的結論存在一些衝突該腳本文件包含

我會嘗試發佈,如果我找到