我试图通过jquery.tokeninput.js制作自动完成数据并在保存时插入数据库,但是现在我将编辑并显示数据没有出现,是否可以显示数据的值?
Views
<input type="text" class='form-control' id="tokenfield" name="name" value="<?php echo $name ?>"/>
<script type="text/javascript">
$(document).ready(function() {
$("#tokenfield").tokenInput("<?php echo base_url(); ?>form/prosedurkerja/get_prosedur", {
classes: {
tokenList: "form-control token-input-list-facebook",
token: "token-input-token-facebook",
tokenDelete: "token-input-delete-token-facebook",
selectedToken: "token-input-selected-token-facebook",
highlightedToken: "token-input-highlighted-token-facebook",
dropdown: "token-input-dropdown-facebook",
dropdownItem: "token-input-dropdown-item-facebook",
dropdownItem2: "token-input-dropdown-item2-facebook",
selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
inputToken: "token-input-input-token-facebook"
}
});
});
控制器
function edit() {
$id = $this->uri->segment(4);
if ($id == NULL) {
redirect('myviews_1');
}
$get_id = $this->mymodel->get_name($id);
$data['id'] = $get_id->id;
$data['name'] = $get_id->name;
$data=array(
'name' => $dt->name,
'id' => $id,');
$this->load->view('myviews_2');
}
模型
function get_name($id) {
$d = $this->db->get_where('mytable', array('id' => $id))->row();
return $d;
}
答案 0 :(得分:0)
按此更改控制器数据
function edit() {
$id = $this->uri->segment(4);
if ($id == NULL) {
redirect('myviews_1');
}
$get_id = $this->mymodel->get_name($id);
$data['id'] = $get_id->id;
$data['name'] = $get_id->name;
$data=array(
'name' => $dt->name,
'id' => $id);
$this->load->view('myviews_2',$data);
}
我希望这对你有所帮助。