简体   繁体   中英

Make table row editable using jQuery, jEditable, jeditable-rails gem or any AJAXy solution

I have a table with rows of data on it. I want most of the row to be editable by clicking either the row itself or an edit button.

Let's say I have a table that lists products:

  • Product Name
  • Brand
  • Model
  • Price

I'm able to accomplish this by using jQuery and jEditable; and also by using the jeditable-rails gem. But I can only edit one cell at a time.

What I need is this: If I click in the Edit button or the row itself. All those four cells in the table should become editable.

Try something like this:

$('td:not(.edit)').editable('', {
    onblur: 'ignore',
    submit: 'ok',
    cancel: 'cancel',
    width: 75,
    event: 'edit'
});

$('td').click(function(e) {
    // reset all editables
    var allEditables = $(this).closest('table').find('td:not(.edit)').get();
    $.each(allEditables, function(i, elm) {
        elm.reset();
    });

    // make all cells in this row editable
    $(this).parent().children(':not(.edit)').trigger('edit');
});

Example: http://jsfiddle.net/UMccc/221/

I found the right path here: jQuery - Edit a table row inline

It doesn't use jEditable.

It's just a Javascript function, but I think it's launch pad for creativity.

Here is an easy to use and flexible jquery inline editable plugin . It let's you to have editable easily anywhere, inside a table or h1 tag, and can covnert anything to anything. actually the idea behind is simple and kinda unique.

Cheers,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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