Skip to content

Instantly share code, notes, and snippets.

@mkelley33
Created December 3, 2012 07:43
Show Gist options
  • Save mkelley33/4193432 to your computer and use it in GitHub Desktop.
Save mkelley33/4193432 to your computer and use it in GitHub Desktop.
best_in_place: fix disappearing line-breaks in textarea
jQuery ->
$('[id^="best_in_place_your_object_"],[id$="address"]').on 'best_in_place:update', (event) ->
$address = $(event.target)
$address.data('bestInPlaceEditor').original_content = $address.html()
$address.html $address.html().replace(/[\n\r]+/g, '<br>')
<h4><%= best_in_place your_object, :address, type: :textarea, display_with: -> v { v.gsub(/[\r\n]+/, '<br>').html_safe } %></h4>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment