Open deemytch opened 9 years ago
@deemytch could you make a sample app with this bug?
Unfortunately no. When I do pure new page outside of project it works as expected, that's why I decided to use that plugin in my project. But inside my project I get no placeholders at all. There's no errors in firefox console, all js code is included without errors in rails log. I spend yesterday full day to clean up all unneeded js code from all views, but without success. Have no more ideas how to debug that. Is there some points inside the lib, so I can check them?
@deemytch you can run internal gem app to test all behaviors by running rackup -p 3000
in gem folder
Ok, I got it. This happens when I load the partial with ajax. What's confusing, is that all other functionality of best_in_place works as expected in such loaded view. Project: https://github.com/deemytch/best_in_place_test
@deemytch ok, I will check your repo
the same thing is happening to me and doesn't seem to be related to ajax.
Could it be related to the initialization? Try wrapping its initializer in a document ready. Like that:
$(document).ready(function() {
$('.best_in_place').best_in_place();
});
I'm also having this issue - was it ever resolved? In my case, the placeholder text doesn't load when I visit the page from a link, but if I refresh the page, it shows up.
This is still an issue, I'm loading the content using js.
<%= escape_javascript(render partial: 'info', locals: {persona: @persona}) %>
Ok so below that line I just added $(".best_in_place").best_in_place();
and it worked. I was loading the script in document.ready but the document has been dynamically updated so I have to do it again. :+1:
I tried the solutions but I can't still get it to work. I'm using best_in_place inside https://github.com/antillas21/ajax-datatables-rails/
I'm having the same problem as @mvassilevsky - missing field only shows after a page refresh. I have the best_in_place initializer in a document ready in the application.js. Any updates on this issue?
@majedian21 I had a similar problem. I was losing my placeholders when browsing around with turbolinks.
Like @acrogenesis said, I just added $(".best_in_place").best_in_place(); to my header so it fires on every load. If you need it to work within a dynamically loaded partial, try adding that line of js to your partial?
Encountered the same problem.
The following is a workaround I did (Fill placeholders when the data is drawed or changed.).
You should specify the place_holder option as follows even when you want to use the default one, '-'.
best_in_place(..., place_holder: '<some_place_holder>')
function fillPlaceHolderOfBestInPlace(that) {
var $that = $(that),
str = $.trim($that.text());
if (!str) {
$that.text($that.data('bip-placeholder'));
}
}
function fillEachPlaceHolderOfBestInPlace() {
$('.best_in_place').each(function() {
fillPlaceHolderOfBestInPlace(this);
});
}
$(function() {
table = $('<id_for_datatables>').DataTable({
:
:
serverSide: true,
ajax: '<ajax_endpoint>',
deferRender: true,
drawCallback: function (settings) {
fillEachPlaceHolderOfBestInPlace();
}
});
$('.best_in_place').best_in_place();
$(document).on('ajax:success', '.best_in_place', function() {
fillPlaceHolderOfBestInPlace(this);
});
});
For me, I had to re-initialize after the table loaded Ajax data.
$ ->
$('#assets-table').dataTable
pageLength: 100
ajax: '/assets.json'
serverSide: true
order: true
deferRender: true
columns: [
{ "data": "filename" }
{ "data": "corrupt" }
]
fnDrawCallback: (oSettings) ->
$('.best_in_place').best_in_place()
@jalevin you saved my day, thanks!
haml code like that:
gets replaced in resulting html with:
and if @dish.descr is nil - nothing was displayed. I see that the place_holder key was replaced with data-bip-placeholder attr, if that matter? I checked variants like
:'place_holder' => , 'place_holder' =>, :'place-holder'
etc, and evendata: { bip: {placeholder: "text"}}
but nothing works.The same thing with other fields types.
Partial with fields to edit was loaded dinamically with ajax, if this does matter.
rails 4.2.0 best_in_place gem 3.0.3 ruby 2.2.1p85