Git Product home page Git Product logo

Comments (10)

zacksiri avatar zacksiri commented on August 28, 2024

perhaps we could do something like this

<%= best_in_place @blah, :field, update_multiple: [[:total], [:whatever]] %>

from best_in_place.

imginit avatar imginit commented on August 28, 2024

This would be extremely helpful, +1

from best_in_place.

taavo avatar taavo commented on August 28, 2024

Can you confirm this isn't already possible by handling the ajax:success event?

from best_in_place.

zacksiri avatar zacksiri commented on August 28, 2024

where would we but the ajax:success? i mean if you have lots of fields you'll be managing a lot of it. it would be nicer to have some kind of way to do it from best_in_place

from best_in_place.

RavWar avatar RavWar commented on August 28, 2024

I can confirm. Here's a simple example using jquery:

$('.best_in_place').change(function() {
  $.ajax({
    success: function() {

    }
  });
});

from best_in_place.

RavWar avatar RavWar commented on August 28, 2024

artellectual, i had the exact same problem: price, quantity, sum displayed in a row and below the table total price of all products, user can change quantity and sum with total price should be updated.
I did it like this:
Moved my order information into a partial, created new route
get 'order_sum', :controller => 'orders', :action => :order_sum
Added this action to a controller to display partial

def order_sum
  render :partial => 'shared/order_sum'
end

Then i add jquery

$('.best_in_place').change(function() {
  $.ajax({
    success: function() {
      $('.order_product_sum').load('/order_sum');
    }
  });
});

But i have a problem with displaying information. Firstly, i wanted to make that only column with sums is in partial and gets updated. But i havent figured out how to display it properly. I tried to move the whole table into partial and when u use it for the first time - everything loads up perfectly, but then best_in_place stops working...

from best_in_place.

RavWar avatar RavWar commented on August 28, 2024

The solution to broken best_in_place after loading the whole table was pretty easy

$('.best_in_place').change(function() {
  $.ajax({
    success: function() {
      $('.order_product_sum').load('/order_sum', function(){
        $('.best_in_place').best_in_place();
      });
    }
  });
});

from best_in_place.

zacksiri avatar zacksiri commented on August 28, 2024

its not the cleanest solution though, you have to create a custom order_sum action. when you update the object using best_in_place it returns the json data anyway it should update the field using that new data, instead of loading the data twice.

from best_in_place.

VonD avatar VonD commented on August 28, 2024

Hi everyone,

I've tried to implement this on my fork of the project, on the update_with branch : https://github.com/VonD/best_in_place
I haven't wrote tests for it yet, but it works fine on my app.
Can you please have a look at it and tell me what you think ?
Please make all comments as it is the first time i put my hands on a gem.
The docs are updated, but here is the syntax :

= best_in_place object, field, :update_with => :other_field

Or

= best_in_place object, field, :update_with => [:other_field1, :other_field2]

In case you need to update an attribute that is never editable, i've introduced a new block syntax :

- best_in_place object do |bip|
   = bip.input field, :update_with => [:other_field1, :other_field2]
   = bip.input other_field1
   = bip.no_edit other_field2

Thanks, I'd like to have opinions before submitting a pull request

from best_in_place.

albertbellonch avatar albertbellonch commented on August 28, 2024

Hello everyone,

We think that the best option for now is to use AJAX callbacks in order to update what you want to be updated in the view. It might not be the best possible solution but, for now, is the most practical approach.

We do not plan to implement this whole feature, but feel free to provide a pull request with tests and the implementation of this.

from best_in_place.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.