[eluser]RMinor[/eluser]
I am using JEditable to allow in-line editing in my website, but have come across an odd issue. Basically, the functionality works. I can click the item, edit it, and save it. It updates everything in the database, but does not display the new value after editing. I tried both echoing out and returning the value from the controller. I've also tried allowing query strings in the config.php file. Nothing works to display the new value. My Firebug result is a status 200 OK message that is in red instead of the usual black. I looked up what the red color means to find that there is some error, however no error is being reported. If anybody has any ideas on how to fix this please share them. My code is below.
Controller
Code:
public function edit()
{
$id = $this->input->post('id');
$name = $this->input->post('value');
if ($this->Category_model->edit($id, $name)) {
return TRUE;
}
return FALSE;
}
Model
Code:
/**
* Method to edit a category.
*/
public function edit($id, $name)
{
$value = $this->_createValue($name);
$query = $this->db->query("UPDATE category SET value = ?, name = ? WHERE id = ?", array($value, $name, $id));
if ($this->db->affected_rows() == 1) {
return TRUE;
}
return FALSE;
}
/**
* Method to create a value for a category name.
* The goal here is to make everything lower case, replace spaces with dashes, and replace ampersands with the word 'and'.
*/
private function _createValue($name)
{
$value = strtolower($name);
$value = str_replace(' ', '-', $value);
$value = str_replace('&', 'and', $value);
return $value;
}
View
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ADMIN PANEL</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/admin-style.css" />
<style type="text/css">
.editableSingle button, .editableSingle input {
padding: 3px;
}
</style>
[removed][removed]
[removed][removed]
[removed]
ddaccordion.init({
headerclass: "submenuheader",
contentclass: "submenu",
revealtype: "click",
mouseoverdelay: 200,
collapseprev: true,
defaultexpanded: [],
onemustopen: false,
animatedefault: false,
persiststate: true,
toggleclass: ["", ""],
togglehtml: ["suffix", "<img src='<?php echo base_url(); ?>images/plus.gif' class='statusicon' />", "<img src='<?php echo base_url(); ?>images/minus.gif' class='statusicon' />"],
animatespeed: "fast",
oninit:function(headers, expandedindices){
//do nothing
}, onopenclose:function(header, index, state, isuseractivated){
//do nothing
}
})
[removed]
[removed][removed]
[removed]
$(document).ready(function() {
$('.ask').jConfirmAction();
});
[removed]
[removed][removed]
[removed]
$(document).ready(function() {
$('.editable').editable('http://www.digrepro.com/admin/categories/edit', {
indicator : 'Saving...',
tooltip : 'Click to Edit',
submit : 'OK'
});
});
[removed]
[removed][removed]
<link rel="stylesheet" type="text/css" media="all" href="<?php echo base_url(); ?>css/niceforms-default.css" />
</head>
<body>
<div id="main_container">
<div class="header">
<div class="logo"><img src="<?php echo base_url(); ?>images/logo.gif" border="0" /></div>
<div class="right_header">Welcome Admin, <a href="<?php echo base_url(); ?>">Visit site</a> <!--| <a href="#" class="messages">(3) Messages</a>--> | <a href="<?php echo base_url(); ?>admin/logout" class="logout">Logout</a></div>
<div class="jclock"></div>
</div>
<div class="main_content">
<?php $this->load->view('admin/menu_view'); ?>
<div class="center_content">
<div class="left_content">
<?php $this->load->view('admin/sidebar_view'); ?>
</div>
<div class="right_content">
<h2>Product Categories</h2>
<p>To edit a category name simply click on it and make your change. Press the "OK" button when done.</p>
<table id="rounded-corner">
<thead>
<tr>
<th scope="col" class="rounded-company"></th>
<th scope="col" class="rounded">Category</th>
<th scope="col" class="rounded-q4"></th>
</tr>
</thead>
<tbody>
<?php foreach ($categories as $category) {?>
<tr>
<td></td>
<td class="editable" id="<?php echo $category['id']; ?>"><?php echo $category['name']; ?></td>
<td><a href="<?php echo base_url(); ?>admin/categories/delete/<?php echo $category['id']; ?>" class="ask"><img src="<?php echo base_url(); ?>images/trash.png" border="0" /></a></td>
</tr>
<?php } ?>
</tbody>
</table>
<a href="<?php echo base_url(); ?>admin/categories/add" class="bt_green"><span class="bt_green_lft"></span><strong>Add Category</strong><span class="bt_green_r"></span></a>
</div><!-- end of right content-->
</div><!--end of center content -->
<div class="clear"></div>
</div> <!--end of main content-->
<div class="footer">
<div class="left_footer">ADMIN PANEL</div>
<div class="right_footer"><img src="<?php echo base_url(); ?>images/indeziner_logo.gif" alt="" title="" border="0" /></div>
</div>
</div>
</body>
</html>