daijinara
Joined 11/27/2020
daijinara said over 3 years ago on StimulusJS, Active Storage and DropzoneJS :
Thank you for your consideration :)

I figured out my datatable_controller.js as below. I hope it is useful to the community members here :D

import DataTable from "datatables.net";
require('datatables.net-bs4');
require('datatables.net-buttons');
require('datatables.net-buttons-bs4');
require('datatables.net-select');

export default class extends ApplicationController {
	static targets = ["table"]

	initialize() {

		const options = {
			keys: !0,
			select: {
				style: "multi"
			},
			language: {
				paginate: {
					previous: "<i class='fas fa-angle-left'>",
					next: "<i class='fas fa-angle-right'>"
				}
			},
		};

		// Init the datatable
		const table = $('#datatable-basic').on( 'init.dt', function () {
			$('div.dataTables_length select').removeClass('custom-select custom-select-sm');
	  }).DataTable(options);
  }

}

daijinara said over 3 years ago on Deeper Dive into StimulusJS :
better to put this line of code.

import Rails from "@rails/ujs";

Otherwise, Rails.ajax call will be undefined.

Also, adding the intergration with select2 would be better, since it does not fire native events. 


daijinara said over 3 years ago on Deeper Dive into StimulusJS :
 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. :)

daijinara said over 3 years ago on Deeper Dive into StimulusJS :
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()    
  }

daijinara said about 3 years ago on Cropping Active Storage Uploads :
  Do you think your solution works on cloud storage service? Because I understand that re-sizing the image only works after the image is uploaded
. How do you return the getURL() if you use cloud storage service like S3? Or this solution is only for local disk service?