troubleshooting Question

JQuery Jeditable Ajax Inline Editing With CakePHP

Avatar of termlimit
termlimitFlag for United States of America asked on
JavaScriptPHP
4 Comments1 Solution2998 ViewsLast Modified:
I created a simple Excel-like table using CakePHP, JQuery, and Jeditable. I have gotten the table to display information just like Excel, some cells are empty while others contain data. I can edit existing cells and can add information to empty cells. The problem though is that when I go to update a cell that was previously new (I clicked an empty cell and typed in 5.00 and hit enter, the data was sent to the server and saved in the database, the cell gets updated, but then realized it was supposed to be 50.00) it only creates new cells. I am using a unique ID for each cell of the table to allow Jeditable to update the cells. The location of each cell is based on a combination of foreign key references, but the value is set through the table.

The problem comes from the fact that I am using an ID that is exploded in PHP to get the values that I need. It is simply value_{ID}_{foreign_id_1}_{foreign_id_2}. With a new entry the {ID} is set to 0. This allows the system to recognize that the entry is new and creates a new value for the cell using the other 2 foreign key values for that location. When the server sends the data back to update the cell, the {ID} remains 0. Even though data exists in the cell now, the cell is still seen as new by Jeditable because {ID} does not get updated.

The question is how can I updated the {ID} of this cell after the save call is made? I have tried every work around I can think of using CakePHP, but can't get it to work. If any one has any ideas I would be appreciative. I have included the code blocks that I am referencing in my text.
<script type="text/javascript">
$(function() {
	$('.click').editable('/controller/action', {
		id        : 'data[Model][id]',
		name      : 'data[Model][amount]',
		type      : 'text',
		tooltip   : 'Click to edit the amount',
		style	  : 'inherit',
		width	  : '90px',
		height	  : '10px'
	});
});
</script>

<html>
<td class="click" style="font-size:12px" id="model_<?php echo $detail['id'];?>_<?php echo $category['id'];?>_<?php echo $year;?>-<?php echo sprintf("%02d", $b+1);?>-01"><?php echo $this->Number->currency($row['amount'], 'USD', array('after' => false, 'zero' => '0.00', 'places' => 2)); ?></td>
</html>

$detail['id'] is either 0 (new/empty cell) or a positive unique integer (existing data).
ASKER CERTIFIED SOLUTION
babuno5

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros