bernat / best_in_place

A RESTful unobtrusive jQuery Inplace-Editor and a helper as a Rails Gem
http://blog.bernatfarrero.com/in-place-editing-with-javascript-jquery-and-rails-3/
1.2k stars 572 forks source link

Cannot set placeholder test or value #491

Open ttseng opened 9 years ago

ttseng commented 9 years ago

In my Rails app, the best in place textarea doesn't hold the value of the textarea on page load. If I edit it, though, it will act as expected. Here is a video of the bug:

https://youtu.be/xA18Odj47sc

This is my code:

<%= best_in_place @collection, :name, :type => :textarea, :nil => @collection.name, :value => @collection.name, :place_holder => @collection.name %>

hrangel commented 9 years ago

Try wrapping its initializer in a document ready. Like that:

$(document).ready(function() {
    $('.best_in_place').best_in_place();
});