[eluser]jiahui[/eluser]
Recently, I found a useful edit inline jquery solution and would like to use in codeIgniter framework.
Following are my project codes:
Controller Page :
Code:
<?php
class Eximporter extends MY_Controller {
function Eximporter()
{
parent::MY_Controller();
$this->load->model('eximporter_model');
}
// --------------------------------------------------------------------
function index($message = '')
{
$data['extraHeadContent']= "[removed][removed]\n";
$data['extraHeadContent'].= "<link type=\"text/css\" rel=\"stylesheet\" href=\"". base_url()."css/eximporter.css\" />\n";
$data['extraHeadContent'].= "[removed][removed]\n";
$data['extraHeadContent'].= "[removed][removed]\n";
$data['message'] = $message;
$data['exporters'] = $this->eximporter_model->get_exporters_details();
$data['totalrecords'] = $this->eximporter_model->countnoofexporters();
$this->load->view('eximporter/index', $data);
}
// --------------------------------------------------------------------
function updateinfo()
{
$id = ($this->input->get_post('id')) ? (int) $this->input->get_post('id') : $this->uri->segment(3);
$this->eximporter_model->update_address1_details();
}
// --------------------------------------------------------------------
View page:
Code:
<?php foreach($exporters->result() as $ppl):?>
<h3><?php echo $ppl->firstname.' '.$ppl->lastname; ?></h3>
<p><font style="font-family:Arial; font-size:12px;"><strong>Address 1 :</strong></font> <b class="editable_textarea" style="display: inline"><?php echo $ppl->address1 ?></b>
<br /><br /><font style="font-family:Arial; font-size:12px;"><strong>Address 2 :</strong></font>
<br /><br /><font style="font-family:Arial; font-size:12px;"><strong>Address 3 :</strong></font></p>
<?php endforeach;?>
I am not sure how to pass the data id and value to updateinfo page. But I include editInline.js like this:
I used firebug to troubleshoot, I can see textarea value there but id no. Any idea about this?
Code:
$(function() {
$(".editable_textarea").editable("eximporters/updateinfo?id=<?php echo $ppl->id ?>", {
indicator : "<img src='../images/root_sys_admin.png'>",
type : 'textarea',
submitdata: { _method: "put" },
select : true,
submit : 'OK',
cancel : 'cancel',
cssclass : "editable"
});
});