jeditable dynamic target value
I'm using jeditable and it works really great! I'm just having some trouble figuring out how to dynamically change the target URL.
jeditable is bound to a table of values that I want to edit inline. So I have:
<td id="<%= col.id %>_<%= i.id %>" class="edit">
The id is a mashup of two values I need to know to edit this item on the server side.
My js is:
$(document).ready(function() {
$('.edit').editable("/items/1", {
id : "column_id_item_id",
submitdata : function(开发者_JS百科value, settings){
return { data_template_id: '<%= @data_template.id%>}', format : 'json'}
} ,
method : 'PUT',
});
});
Note the target url is "/items/1"
That /1 is what I need to change, and its one of the values built in to the td's id.So my question is how do I take the value from the id of the element clicked and use it to modify the target parameter for jeditable.
Everything else is working fine, I'll just edit item 1 every time right now :)
Set onsubmit to a function and change the target there.
$('whatever').editable("", {
onsubmit: function (settings) {
settings.target = "/set/target/to/whatever/you/like";
}
});
精彩评论