using http://blog.bernatfarrero.com/in-place-editing-with-javascript-jquery-and-rails-3/
Gem uses json to update, but how can I get update.js.erb to update different parts of my pages?
EDIT Using this on the invoice page. Each item in the invoice has a price field that can be updated using best_in_place.
I need to update the total price for a position and the amount due due to the invoice only after a successful field update.
Finished with something like:
respond_to do |format| if @item.update_attributes(params[:item]) format.html { redirect_to order_url(@item.order_id), :notice => "Successfully updated item." } format.js { } format.json { head :ok }
Edited line best_in_place.js # 175
loadSuccessCallback : function(data) { this.element.html(data[this.objectName]); // Binding back after being clicked $(this.activator).bind('click', {editor: this}, this.clickHandler); if(this.objectName == "item") $.getScript('update.js'); // If its an item, call update.js.erb },
source share