繁体   English   中英

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

[英]all fields editable at same time using jeditable

我正在使用Ruby on Rails中的jeditable。

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

这是我的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>

这是展示页面

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

我想设置一个像这样的按钮

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

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

java脚本

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

按键

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM