I have a Rails 7 App that I’m using Importmap with. I’m loading the Bootstrap JS via the gem and docs so my config/importmap.rb has: config/initializers/assets.rb application.js Stuff like dropdowns activated via data attributes work well but my custom JS gives the error: Uncaught TypeError: bootstrap.Popover is not a constructor Answer How to initialize Popper (tooltips) with importmaps You’re very
Tag: ruby-on-rails
Updating a rails record with vanilla javascript
Is it possible to update a rails record with vanilla javascript without intercepting the data and converting it to a hash in the controller? Here is my code: If I just send the data without stringifying it, it shows up in the rails controller at user: [object, object]. In the update action I update the params like this: params[“user”] =
Rails 7 JavaScript event listeners stop working after browser back?
I have rails 7 app where I’m trying to build a search bar using either tom-select or slim-select. My issue reproduces no matter which library I’m using therefore it must be the issue on my rails side. app/views/cities/index.html.erb and this is my js controller (in this case I’m using tom-select) app/javascript/controllers/ts/search_controller.js app/controllers/cities_controller.rb Problem Repro: Open cities index and click on
How to have JS onpaste event work with Rails form?
I have a search form, and would like it so that when I paste something into the form, it automatically submits the form. I would also like to retain functionality so if I don’t paste something, and rather manually type it, that I have to press enter/search button for it to work. Here is my form: Could somebody tell me
Building an web app to run inside other apps through a JS code-snippet
I was given the task to develop sliders/pop-ups for customers of the company I work for. This works a bit like chatbots (ie. Intercom). The user sees a small bubble on the bottom-right corner, clicks on it and it shows some information from our (Rails) app. What’s the best way to create a javascript code to share with those clients?
Bootstrap 5 Javascript Functions not Working in Rails 7 app
I’m trying to set up my first Rails 7 app and have installed Bootstrap 5 properly (you can see by the CSS) and gotten rid of all the error messages, but the javascript functions (i.e. dropdown menus, offcanvas, etc.) aren’t working. I have tested it with this code: And both console.log statments produce the correct result, leading me to believe
Update textfield using a selectbox in ruby on rails
I am new to rails and I have a form below where I need to update a text field(car price) using the option selected in the select box (adjust price). drop down needs to have multiple percentage option like 100% , 50% and 25%. when one percentage is selected then it should update the car price in the field with
Vue.js – How to bind to form elements generated after page load?
I have form elements aren’t available in the html document until an inline script runs on page load. How to I bind to these form elements in Vue.js after the page loads? Obviously with jQuery I could do a $(‘.element’).each(), but what is the ‘Vue way’? I need to set the valueattribute of the hidden inputs. Answer The answer for
How can I execute JavaScript when a new Turbo Frame is loaded
I am using Turbo Frames in my Rails app and have, on every page This loads in fine, and when a link is clicked replaces the frame as expected. In this frame I have set overflow-y: scroll, creating a scrollable frame on the page. Every time a new page is loaded in the frame, I want it to scroll to
Submit a form to Rails backend with ReactJS
It is my first time working with ReactJS in a Rails solution and the task is an emergency request that doesn’t give me enough time to learn React before taking up the sprint to work on. The Backend is a JSON (API) solution and I have been able to write a ReactJS to render the GET endpoint to list the