javascriptruby-on-railsbest-in-place

best in place edit not working on live site


best in place edit not working on the production. I am using the text field with pencil on click on that text field must be shown up. When I ran javascript code at my website console it works.

Here is the code:

jQuery(".best_in_place").best_in_place();

Image of my site UI where I have used best in place:

Pencile in the image open the text field to edit text

this is my html code

     <div class="col-md-7">
   <div class="col-md-2 text-right">
     <%= best_in_place_if can?(:update_organization_with_bip, @organization), @organization, :maximum_sponsor_spend_per_month, :as => :input, activator: "#edit-sponsor_max_spend_per_month", url: {action: :update_organization_with_bip , id: @organization.id},inner_class: "form-control", :classes => 'bounce_on_success' %>
   </div>
   <div class="col-md-1 text-left">
     <%= link_to("<i class='fa fa-pencil'></i>".html_safe, "javascript:void(0);", id: "edit-sponsor_max_spend_per_month",class: "text-danger") %>
   </div>
 </div>

Solution

  • I had similar issue (deployed on heroku) Using gem of best_in_place 3.0.3

    I see that helper work and generate html structure.

    After a lot of time i found that only this helped me: (put in show view)

    <%= content_for :javascript do %>
      <script>
        $(document).ready(function(){
          jQuery(".best_in_place").best_in_place();
        });
      </script>
    <% end %>
    

    Yes, i have similar in my js file in assets js file that working locally