嘿伙计们正在尝试使用codeigniter笑脸辅助函数在我的聊天室中显示表情符号,但是如果我点击笑脸没有显示任何内容,我只是在控制台中收到javascript错误Uncaught ReferenceError: insert_smiley is not defined
这是我的控制器
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->helper('smiley');
$this->load->library('table');
}
public function index(){
//If the user is logged in then load the chat room
if($this->session->userdata('logged_in')){
//Add the smileys in the chat room!
$image_array = get_clickable_smileys(base_url()."img/smileys/", 'msg_input');
//Generate the a table where the smiley faces will be displayed!
$col_array = $this->table->make_columns($image_array,8);
$data['display_smileys'] = $this->table->generate($col_array);
$data['main_contents'] = 'room_view';
$this->load->view('includes/template', $data);
}else{
//if the user is not logged display login form to the his/her username!
$data['main_contents'] = 'site_home';
$this->load->view('includes/template', $data);
}
}
这是我的观点
<div class="container">
<?php echo $display_smileys; ?>
</div>
<li class="divider"></li>
<li><a href="#">Smiley Faces</a></li>
</ul>
</span>
<input type="text" id="msg_input" name="msg_input" class="form-control input-lg" aria-label="Amount (to the nearest dollar)" placeholder="Type here your message">
<span class="input-group-btn"><a href="#" class="btn btn-primary btn-lg" id="send_msg">Send</a></span>
</div>
</div>
感谢您的支持
答案 0 :(得分:0)
您需要回复smiley_js()
才能使其正常工作:
<?php echo smiley_js(); ?>