best_in_place icon indicating copy to clipboard operation
best_in_place copied to clipboard

display_with: :number_to_currency not showing currency after update

Open migu0 opened this issue 10 years ago • 5 comments

Awesome gem!

When using display_with: :number_to_currency, the currency symbol disappears after updating the field. Everything else is working fine.

migu0 avatar Mar 26 '14 05:03 migu0

This is because of turbolink (aka turbo-break-everything-ever). You need to trap the ajax:success event on the field you want to display correctly.

You also have to make sure you're looking for "ready" not just "page:load" events. Here's a working example I use:

$(window).on 'ready page:load', ->  
  $('.default_cost').bind 'ajax:success', ->
    cost_field = $(this).find('span').first()
    cost = Number(cost_field.text()).toFixed(2)
    cost_field.text("$" + cost)
    return

mikbe avatar May 09 '14 23:05 mikbe

I have tried with your example, but its not working.

vuppalasrinivas avatar Mar 09 '15 11:03 vuppalasrinivas

@vuppalasrinivas The solution is to use "respond_with_bip". I had the same problem but using that in my controller action fixes it. See here: https://github.com/bernat/best_in_place#controller-response-with-respond_with_bip

tparkin avatar Mar 19 '15 19:03 tparkin

@seuros display_with (;

stereodenis avatar Mar 20 '15 20:03 stereodenis

Yea... respond_with_bip works very nice.

duleorlovic avatar Nov 07 '15 11:11 duleorlovic