2014-06-09 2 views
0

Jquery/Javascriptcodeigniter에서 작동하지 않습니다. 무엇 내가 한 일은 내가 codeigniter에서 jquery를 사용하여 경고 할 때 아무런 변화가 없습니다

<?php $this->jquery->click('#username', $this->jquery->alert("hi")); ?> 

을 포함하지만 아무 일도하지 내가 views/register.php에서

public function __construct() 
    { 
     parent::__construct(); 
     $this->load->library('javascript'); 
     $this->load->library('javascript/jquery'); 
    } 
    public function index() 
    { 
     $data['library_src'] = $this->jquery->script(); 
     $data['script_head'] = $this->jquery->_compile(); 

     $this->load->view('register', $data); 
    } 

을 포함 config.php에서

내가 controller/welcome.php에서

$config['javascript_location'] = 'libraries/javascript/jquery.js'; 
$config['javascript_ajax_img'] = 'images/ajax-loader.gif'; 

을 포함한다. 오류가 표시되지 않습니다. 이벤트를 Codeigniter에 만들려면 어떻게해야합니까? 이와 관련된 질문은 다른 사람들에게 물어 보지만 아직 해결책을 찾을 수 없습니다. 중복으로 표시하지 마십시오.

감사합니다.

편집

CI에 jQuery를 사용하기위한 어떤 다른 방법 (어떤 식 으로든). 간단히 CI에서 jquery를 만들 수 있습니다.

자산/JS 프로젝트의 루트에라는 당신이 할 수있는 이전 버전 있지만 새 폴더에 자바 스크립트 라이브러리를 수의 나 때문에 당신이 CodeIgniter를에 포함 된 버전이 아닌 자바 스크립트로 jQuery를 사용하는
+0

js와 php를 결합한 이유는 무엇입니까? $ this-> load-> library ('javascript')는 무엇인가? $ this-> load-> library ('javascript/jquery'); –

+0

@RakeshSharma, http://ellislab.com/codeigniter/user-guide/libraries/javascript.html에서 가져 왔습니다. 내가 $ this-> load-> library ('jquery')를 사용할 때; 이 오류가 요청 된 클래스 jquery로드 할 수 없습니다. – next2u

+0

codeigniter에서 jquery 작업 할 수있는 어떤 방법이 있습니까? – next2u

답변

0

I 조언

및 다음과 같이보기에 포함 시키십시오.

<html> 
    <head> 
      <script src="<?=base_url()?>/assets/js/jquery.js" type="text/javscript"></script> 
<script> 
    $(document).ready(function(){ 
      $("#username").click(function(){ 
       //your code here 
      }); 
    }); 
</script> 
    </head> 
+0

감사하지만 작동하지 않습니다. jquery.1.8.3.js를 포함하고 코드를 작성하십시오. 나는 시도했지만 작동하지 않습니다. jquery를 작업 할 수있는 방법이 있습니까 – next2u

+0

크롬 devTools wheather에서 콘솔을 확인하십시오. 오류가 발생하여 –

+0

을 사용할 때 빈 페이지를 얻을 때 base_url을 사용합니다. – next2u

관련 문제