可编辑的动态目标值

发布于 2024-08-28 22:07:35 字数 707 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

将 onsubmit 设置为一个函数并在那里更改目标。

$('whatever').editable("", {
            onsubmit: function (settings) {
                settings.target = "/set/target/to/whatever/you/like";
            }
        });

Set onsubmit to a function and change the target there.

$('whatever').editable("", {
            onsubmit: function (settings) {
                settings.target = "/set/target/to/whatever/you/like";
            }
        });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文