我正在使用jeditable,它真的很棒!我只是在计算如何动态更改目标URL时遇到了一些麻烦。
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绑定到我想要内联编辑的值表。 所以我有:
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">id是在服务器端编辑此项目时需要知道的两个值的混搭。
The id is a mashup of two values I need to know to edit this item on the server side.
我的js是:
$(document).ready(function() { $('.edit').editable("/items/1", { id : "column_id_item_id", submitdata : function(value, settings){ return { data_template_id: '<%= @data_template.id%>}', format : 'json'} } , method : 'PUT', }); });注意目标网址是/ items / 1 那个/ 1是我需要改变的,以及它在td id中内置的值之一。
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.
所以我的问题是如何从id的值中获取值元素点击并用它来修改jeditable的目标参数。
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.
其他一切正常,我现在每次只编辑第1项: )
Everything else is working fine, I'll just edit item 1 every time right now :)
推荐答案将onsubmit设置为函数并在那里更改目标。
Set onsubmit to a function and change the target there.
$('whatever').editable("", { onsubmit: function (settings) { settings.target = "/set/target/to/whatever/you/like"; } });更多推荐
可裁剪的动态目标值
发布评论