可编辑的动态目标值
我正在使用 jeditable,它的效果真的很棒!我只是有点难以弄清楚 了解如何动态更改目标 URL。
jeditable 绑定到我想要内联编辑的值表。 所以我有:
<td id="<%= col.id %>_<%= i.id %>" class="edit">
id 是两个值的混搭,我需要知道它才能在服务器端编辑此项目。
我的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',
});
});
注意目标url是“/items/1”
/1 是我需要更改的内容,它是 td id 中内置的值之一。
所以我的问题是如何从单击的元素的 id 中获取值 并用它来修改 jeditable 的目标参数。
其他一切都工作正常,我现在每次都会编辑第 1 项:)
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(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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 onsubmit 设置为一个函数并在那里更改目标。
Set onsubmit to a function and change the target there.