Hi, i am following the stimulus learning path, but after the first video, when i try to see this one, i feel i miss something else, what video # should i see first to get here?
☒ One thing that has changed from the earlier videos is that now I use rails webpacker:install:stimulus to install stimulus. I think that #189 or #207 are great starting guides. I think that it's one of those things where it will take practice to get use to it. I often refer back to the handbook which has lots of great information. https://stimulusjs.org/handbook/introduction
Great! is good to know. I wanna say thank your support. I did not have problems with that change, because indeed i looking for documentation while im watching this video. Now i realize that i was confused on how the video started. I thought that all the accounts , cities, countis, settings model were already made before this video, but when i finished it, i noticed that all the practice was perfectly explained. Thank you
☒For people like me who is hobbyist and only learned functional language such as ruby, I really appreciate your teaching style in explaining each line of codes on the city_selector_controller.js. :)
For those seeking to integrate select2, add this code below:
initialize() {
console.log('hello from city-selector controller')
$("#state_id, #county_id").on('select2:select', function () {
let event = new Event('change', { bubbles: true }) // fire a native event
this.dispatchEvent(event);
});
this.check_forms()
}
Otherwise, Rails.ajax call will be undefined.
Also, adding the intergration with select2 would be better, since it does not fire native events.
However, on modern setups where webpacker is present and the asset pipeline is no longer handling the JS, you're absolutely correct.