Jquery 使用表格可同时编辑所有字段
我正在使用Ruby on Rails中的jeditable 我试图做的是单击一个按钮,某一行的所有字段都将变为可编辑状态,并自动变为可编辑状态。这可能吗 这是我的java脚本Jquery 使用表格可同时编辑所有字段,jquery,ruby-on-rails,ruby-on-rails-3,jeditable,Jquery,Ruby On Rails,Ruby On Rails 3,Jeditable,我正在使用Ruby on Rails中的jeditable 我试图做的是单击一个按钮,某一行的所有字段都将变为可编辑状态,并自动变为可编辑状态。这可能吗 这是我的java脚本 <script> jQuery(document).ready(function($) { $(".edit_textfield").each( function() { $(this).editable('<%= @student.id%>', {
<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>
$(".edit_trigger").bind("click", function() {
$(".edit_textfield").click();
});
jQuery(文档).ready(函数($){
$(“.edit_textfield”).each(function(){
$(此)。可编辑(“”{
指标:'Saving…',
工具提示:“单击以编辑…”,
行:10,
方法:“放”,
submitdata:{id:$(this.attr('id'),name:$(this.attr('name')}
});
});
});
这是展示页面
<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脚本
<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>
$(".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>
单击此按钮,所有字段都将变为可编辑!