【问题标题】:all fields editable at same time using jeditable使用 jeditable 同时编辑所有字段
【发布时间】:2013-01-14 08:33:03
【问题描述】:

我正在使用 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>

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

【问题讨论】:

    标签: jquery ruby-on-rails ruby-on-rails-3 jeditable


    【解决方案1】:

    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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-13
      相关资源
      最近更新 更多