Jquery – Jeditable setting default selected value after change

jeditablejquery

My app allows the user to update a field via a drop down box using jeditable. When the program is loaded i created this function to get the selected value and set it as the selected value in jeditable.

But after i change the value, the selected tag stays set as the old value. how can i make it change to the new value?

this is the function

function updateType(ID,type){
$(document).ready(function(){

    $('#tweekType-'+ID).editable("edit.php?type=tweekType", {  

    data   : " {'copywriting':'Copywriting','design':'Design','code':'Code', 'selected':'"+type+"'}",
    type   : 'select'

    });
});

this is the wrapper around the tag.

<span id="tweekType-<?php echo $getTweaksReturned->tweekID; ?>">
<?php type($getTweaksReturned->type); ?>
<script>updateType('<?php echo $getTweaksReturned->tweekID; ?>','<? echo $getTweaksReturned->type; ?>'); </script>
</span> 

The same tag is replicated on the page the returns the new variable.

Best Solution

I've had the same issue. The answers given here are not to the point.

Anyway, I solved it with a pretty simple and neat solution:

Just don't add the 'selected' key and value.

Every time you open the select box it's automatically on the value of the cell...

Hope this helps.