Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

all fields editable at same time using jeditable

I am working with jeditable in Ruby on Rails.

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

<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

like image 331
Okky Avatar asked Aug 16 '26 11:08

Okky


1 Answers

java script

$(".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>
like image 197
Nithin Viswanathan Avatar answered Aug 17 '26 23:08

Nithin Viswanathan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!