所有字段都可以使用jeditable同时编辑

时间:2021-01-20 11:48:29

I am working with jeditable in Ruby on Rails.

我正在使用Ruby on Rails的jeditable。

I’m trying to do is click a button and all the fields a certain row become editable and automatically go to their editable state. Is this possible?

我要做的是点击一个按钮,某一行的所有字段都变成可编辑的,并自动进入可编辑状态。这是可能的吗?

This is my java script

这是我的java脚本

<script>
jQuery(document).ready(function($) {
    $(".edit_textfield").each( function() {  
          $(this).editable('<%= @student.id%>', {
                indicator   :'Saving...',
                tooltip     :'Click to edit...',
                rows        :10,
                method      :"PUT",
                submitdata: {id: $(this).attr('id'),name: $(this).attr('name')}
            });
    });
});
</script>

This is the show page

这是展示页面。

<p>
  <b><%=t :Name%>:</b>
  <dd class="edit_textfield" id="<%= @student.id %>" name="name"><%= @student.name %></dd>
</p>

<p>
  <b><%=t :Age%>:</b>
  <dd class="edit_textfield" id="<%= @student.id %>" name="age"><%= @student.age %></dd>
</p>

<p>
  <b><%=t :Address%>:</b>
  <dd class="edit_textfield" id="<%= @student.id %>" name="address"><%= @student.address %></dd>
</p>

<p>
  <b><%=t :Phone%>:</b>
  <dd class="edit_textfield" id="<%= @student.id %>" name="phone"><%= @student.phone %></dd>
</p>

I want to setup a button like

我想设置一个按钮

<button type="button" id="button1">Click this button and all the fields will become editable!</button>

so that by clicking this i want to make all fields editable

通过点击这个,我想让所有的字段都可以编辑。

1 个解决方案

#1


4  

java script

java脚本

$(".edit_trigger").bind("click", function() {
    $(".edit_textfield").click();
});

Button

按钮

<button type="button" class="edit_trigger">Click this button and all the fields will become editable!</button>

#1


4  

java script

java脚本

$(".edit_trigger").bind("click", function() {
    $(".edit_textfield").click();
});

Button

按钮

<button type="button" class="edit_trigger">Click this button and all the fields will become editable!</button>