-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage in Rails 6 #620
Comments
I am also trying to use with Rails 6. I am finding that it shows the text but doesn't allow it to be editable... |
me too |
How did you import the library? Can you Show me a code sample? :) |
I put this into gem file
then this into application.js
and then also pasted this into application.js:
|
Yeah. For me too. Can't make it editable cause require("best_in_place") in application.js is not working. Uncaught TypeError: $(...).best_in_place is not a function is shown in console. |
Are there any other alternatives as good as best_in_place for rails 6? |
Unfortunately I didn't find anything. Seems like we have to use pure Javascript/JQuery. |
Yeah. I was trying Jinplace in which it creates POST request and always triggers create action.There is no clear documentation on sending different requests. https://github.com/itinken/jinplace |
I found a relatively new plugin which I will try to get to work, that looks quite promising: |
@alliedarmour Great. Let me know how it works after trying. |
@Praveenkj just wanted you to know that I found a working solution: I'm using Inplace.js. |
do the following for make it work in rails 6:
|
Thanks, yeah it's working Like that. Didn't know you can add .erb-support to Webpacker :D. Thanks Mate! |
No go for me with the above. Webpacker complains, it cannot find jquery:
I definitely have it installed. Does this have to do with erb support ? |
I think it may be complaining about the //= require jquery.autosize Edit: It's not complaining about the e.g. I'm upgrading a project so the resolved_paths: ["app/assets", "vendor/assets"] I've moved import "javascripts/best_in_place"; And it appears to be imported without error. I haven't tested in app yet, as I still have more js libs to resolve. |
Hi @davegudge I followed what u said I added a copy of best_in_place.js in my lib/assets/javascripts Then import "javascripts/best_in_place"; in my application.js I also added another copy of import "javascript/best_in_place"; into javascript/pack dir Module not found: Error: Can't resolve 'jquery/src/jquery' in '/home/ubuntu/.rvm/gems/ruby-2.6.3/bundler/gems/best_in_place-c0bc9c8ad3e1/lib/assets/javascripts' Module not found: Error: Can't resolve 'javascripts/best_in_place' in '/home/ubuntu/environment/apartment/app/javascript/packs' Any suggestion? Thanks, |
Hi @Amm1r-IT, I haven't got as far as committing this change to the project I'm working on (as other things have come up (unrelated)), but I still have the changes stashed locally. However, looking at your comment, if you're placing the file in e.g.: resolved_paths: ["lib/assets"] Hopefully that will resolve your issue? |
Hi @davegudge thanks for your feedback the issue is solved , i think it was on how to import the best_in_place.js file i just added a copy into my pack folder and import it in application.js with only these lines in my application.js for the gem ` $(document).ready(function() { ` Thanks, |
For me, this issue was order related. I knew it should be working because I have it working in other Rails 6 projects. I don't use Webpacker in any of my Rails 6 projects. I use the old asset pipeline. But this one was giving me this Uncaught Type error. The only difference is I decided not to use Webpacker again for this new Rails 6 app and I'm barely using the old asset pipeline. In order to get this working, I had to move : <%= javascript_include_tag 'admin/application' %> to the bottom of my layout template right above because I'm not loading any jquery inside application.js. I have it linked directly in the layout (bypassing the asset pipeline). Once, I had application.js loading AFTER all my other JS scripts that are below the footer, it works fine. I'm not saying that needs to happen in your application, only that it was an order issue with mine because of the way I'm loading my assets in this new project. |
@alliedarmour did you have a tutorial or something you used for this? I'm new to rails and trying to get some in place editing going. Any help would be appreciated! |
@bborstad I don't use it anymore, I implemented my own in place editing. Take a look at StimulusJS / Stimulus Reflex, it's easy to get it working with this and you can use it for many things throughout your project (real time interactions over ActionCable websockets). |
@alliedarmour thank you! |
Hello, I did small updates for Rails 6 / Webpack and a Turbo (successor of Turbolinks) update for Best in place. I have this in my javascript/packs/application.js:
Obviously it is not updated for the modern web, so I try to trigger here and then, I even written a very small stimulus controller to trigger it in page-part refresh without calling JS directly. This version introduce two dependencies to add with yarn or npm: "autosize" and "autosize-input". Updated source: https://gist.github.com/poqudrof/0cf74465841f0fed0f6e4afe6ddc89e4 Tested to work in Rails 6.0. I hope it could be useful to anyone 😄 . I am still not ready to rewrite a subset of it like @alliedarmour , I guess it would be a nice update to rewrite it without with Stimulus/Turbo instead of JQuery. Cheers, |
i'm also stuck with the same problem i can see the text but it is not editable |
Can you help me with the same problem? |
Thanks dear, Your solution helped me, I was stuck like for more than a day because of this problem. |
Saved my life, I'm returning to use Rails front-end after Rails 7 and Turbo and was at the point of headbuting the wall haha This worked for me just fine, thank's a lot! |
Hello, Instead of a import { Controller } from "@hotwired/stimulus"
// Trigger a refresh of Best in place.
export default class extends Controller {
connect() {
$(".best_in_place").best_in_place();
}
} Cheers, Jeremy. |
I used Stimulus solution keeping sprockets. Works nicely. Guess I should move to more modern Webpacker eventually? Thanks all |
Hi,
currently, I'm trying to use the best_in_place gem with my Rails 6 application, but since I use Webpacker I'm not able to figure out how to get the gem to work, cause the readme is kind of outdated.
If I Add
//= require best_in_place
or (newer)require("best_in_place")
it's just not found.So if anyone uses this gem in a Rails 6 application, how do you import the js-file?
Thanks for any help!
`
The text was updated successfully, but these errors were encountered: