简体   繁体   中英

edit-in-place problem with sending GET data

$('.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.

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')}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM