views:

68

answers:

1
$('.textedit').editable('/challenge/skeleton/textedit/textedit/process', {
    loadurl: '/challenge/skeleton/textedit/textedit/loadraw',
    loaddata: {id: $(this).attr('id'), client: $(this).data('client')},
    submitdata: {id: $(this).attr('id'), client: $(this).data('client')},
    ....
});

$('#textedit_footer').data('client', 5);
$('#textedit_home1').data('client', null);
$('#textedit_test').data('client', 3);
$('#textedit_userCreate').data('client', null);

My problem lies with the GET data being sent. The 'id' data gets sent appropriately, but the 'client' data does not. I think I am using data() the wrong way but can't put my finger on it. Any suggestions? Or any suggestions on how to do this in a better way? Here is an example of one of the divs:

<div class="textedit" id="textedit_home1">
<p>test</p>
</div>

All the .textedit elements are edit-in-place features. When the data is submitted (specified in submitdata and loaddata), two data packets should be sent to the server so that it knows how to process it: the first is the id of the edit-in-place, which is stored as the id of the element (this part works). The second piece of data I call the 'client'. The only way I can think of the browser to know which elements have which client is via data(). But some reason my implementation is not working. The 'client' data is simple not sent, that's what's wrong.

+1  A: 

revised answer...

When you create the closure the value is null if you happen to set it later it does not affect the submitdata xhr call as that data has already been 'closed' for want of a better word. It will not evaluate the data('client') at the time of sending.

Update

Looking at the plugin you can do somehting like this

$(".editable").editable("http://www.example.com/save.php";, {
   submitdata : getData
});

function getData(){
       return {id: $(this).attr('id'), client: $(this).data('client')}
}
redsquare
That doesn't make sense to me but I'll try it... Because I thought loaddata and loadurl are executed only when needed, which is when the edit-in-place is clicked...
Jonah
Nope, setting the data first and then writing the editable() part of the code makes no difference... am I going about this correctly?
Jonah
No idea, I'd reall need to debug, can you put your page live. If not are you familiar with firebug? You could put breakpoints in your js and step through what the plugin does and find out why the values dont get sent.
redsquare
That's it!! thanks!
Jonah
No worried, good luck
redsquare