开发者

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 开发者_StackOverflow中文版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,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜