bootstrap-ruby / bootstrap-editable-rails

In-place editing with Twitter Bootstrap for Rails
http://rubygems.org/gems/bootstrap-editable-rails
MIT License
216 stars 52 forks source link

Updating nested attributes #1

Open ingithub opened 11 years ago

ingithub commented 11 years ago

Hi,

this gem is working great and nice tutorial how to implement it, but how can I update nested attributes?

Thanks

ghost commented 11 years ago

How can I access to value? I need assign it to name:

%a{href: '#', class: "editable_#{post.id}", 'data-url' => post_path(post)}= post.name
:javascript
  $(".editable_#{post.id}").editable({
      type: 'text',
      title: 'Enter username',
      params: {
        post: {
          post_translations_attributes:{
            id: "#{post.translation.id}",
            name: 'This value'
          }
        }
      }
  });
tkawa commented 11 years ago

Thank you for using! I update the repo to enable to overwrite params yesterday. (not released yet)

With a head of the repo, how about this:

gem 'bootstrap-editable-rails', github: 'tkawa/bootstrap-editable-rails'
<% @member.posts.each_with_index do |post, i| %>
  <a href="#" class="post_body" data-type="text" data-resource="member[posts_attributes][<%= i %>]" data-id="<%= post.id %>" data-name="body" data-url="/members/1" data-original-title="Enter body">body</a>
<% end %>
$(".post_body").editable({
  params: function(params) { // for ovewrite params
    params[$(this).data('resource') + '[id]'] = $(this).data('id');
    return params;
  }
});

I'm going to think of a better spec for nested attributes.

burtondav commented 11 years ago

tkawa - I don't understand the status of this issue. Are we supposed to be able to use the above code to fix the issue of editable columns in tables? It doesn't fix it for me.

I used the code above. I now get a popup for every row. I can change the data. But, the record doesn't get changed in the database.

bytheway875 commented 10 years ago

Hi! Was there ever a feature added that allowed for editing nested attributes? It's working great for everything but my nested attributes. :-/