CodeIgniter Forums
Edit in place with jQuery -> jEditable question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Edit in place with jQuery -> jEditable question (/showthread.php?tid=3358)



Edit in place with jQuery -> jEditable question - El Forum - 09-26-2007

[eluser]codex[/eluser]
Is anyone using this? If so, I'm having a bit of trouble understanding how to send data to the server.

Well, actually I DO understand, but the problem is that I'm using CI url routing.

Instead of posting data to editdata.php (which I know how to do) I need to send it to /editdata/, and this is where I get stuck.


Code for jEditable is:

Code:
$(document).ready(function() {
    $("#editable1").editable("http://www.domain.com/editdata/", {
        indicator : "<img src='img/indicator.gif'>",
        type      : 'textarea',
        onblur    : 'cancel',
        tooltip   : 'Click to edit...',
        cancel    : 'Cancel',
        submit    : 'OK'
    });
});


Sending it like this 'http://www.domain.com/editdata/data_here' works, but how do you get data at the 'data_here' spot?

Anyone an idea?


Edit in place with jQuery -> jEditable question - El Forum - 09-26-2007

[eluser]ELRafael[/eluser]
I never used jQuery... but in scriptaculuos, i needed a thing very similiar to you

I've a autocomplet, and when the user select the item, i need the id (from database) of that selected item and pass like this
www.site.com/app/method/id_of_selected

Code:
function setCidadeId(inputField, selectedItem)
{
  $('id_cidade').value = selectedItem.id;
}

the id_cidade is a hidden input. You can change whatever you need.

sorry if is not what you are looking for.


Edit in place with jQuery -> jEditable question - El Forum - 09-26-2007

[eluser]codex[/eluser]
Thanks, but it doesn't help :-)


Edit in place with jQuery -> jEditable question - El Forum - 09-26-2007

[eluser]gunter[/eluser]
so editdata is your function name in your controller?

I think the data is passed as POST variable to your function
so it would be helpful to save or log the POST array to see what is going to your function...


Edit in place with jQuery -> jEditable question - El Forum - 09-26-2007

[eluser]codex[/eluser]
Hi, I was just about to post that I've solved it with enabling query strings in config.php

$config['enable_query_strings'] = TRUE;

It works now, so thanks.


Edit in place with jQuery -> jEditable question - El Forum - 09-26-2007

[eluser]gunter[/eluser]
oh, I thought the data is passed as POST and not as query string...
be careful if the data has forbidden letters


Edit in place with jQuery -> jEditable question - El Forum - 09-26-2007

[eluser]codex[/eluser]
Yeah, I'd rather not use query strings, but I think it's the only way to pass stuff through jEditable. There is an option however to pass data not via an url, but via a function. But I don't understand how. So for now this will do :-)


Edit in place with jQuery -> jEditable question - El Forum - 09-27-2007

[eluser]slith[/eluser]
include the "id" and "name" parameter, example:

Code:
$("#editable1").editable("http://www.domain.com/editdata/", {
        indicator : "<img src='img/indicator.gif'>",
        type      : 'textarea',
        id        : 'field'
        name      : 'field_name'
        onblur    : 'cancel',
        tooltip   : 'Click to edit...',
        cancel    : 'Cancel',
        submit    : 'OK'
});

then in your controller you retrieve the value with:

Code:
$this->input->post('field_name')

this is in the jeditable docs under "What is sent to server?"

but now that i think about it you should be able to retrieve the value using this same method [in your controller] even if you dont specify "id" and "name". these are only necessary if you want to change the default field parameters (specified in your html).

so if your html looks like this

Code:
&lt;textarea name="field_name" id="field"&gt;&lt;/textarea&gt;

jeditable will submit a post which you can then retrieve in your controller using

Code:
$this->input->post('field_name')

i hope this makes sense.


Edit in place with jQuery -> jEditable question - El Forum - 09-27-2007

[eluser]codex[/eluser]
Thanks a lot!!

This helps a great deal. I was focusing on the query string and did not realize that you don't actually need to read the url to know what has been posted. Just use, like you said, $this->input->post('field_name') and that's it.

Thanks!!


Edit in place with jQuery -> jEditable question - El Forum - 09-27-2007

[eluser]gunter[/eluser]
wow! thats great! I tried it now by myself and it´s so easy!!!

thanks for bringing jeditable into my life!!!!!