jeditable dynamic target value

夙愿已清 提交于 2019-12-06 12:05:37

问题


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 :)


回答1:


Set onsubmit to a function and change the target there.

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


来源:https://stackoverflow.com/questions/2631282/jeditable-dynamic-target-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!