Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Import stimulus
import { Application } from "stimulus";
import { definitionsFromContext } from "stimulus/webpack-helpers";
document.querySelectorAll("a[data-form-submit]").forEach(function (element) {
element.addEventListener("click", function(event) {
// We're turning this element into a form submission, so instead of the
// default action, this event will handle things.
event.preventDefault();
// Find the form identified by our formSubmit, and submit it.
document.querySelector("form#" + element.dataset.formSubmit).submit();
});
});
const application = Application.start();
const context = require.context("./controllers", true, /\.js$/);
application.load(definitionsFromContext(context));
// Load all the controllers within this directory and all subdirectories.
// Controller files must be named *_controller.js.
import { Application } from 'stimulus'
import { definitionsFromContext } from 'stimulus/webpack-helpers'
import StimulusReflex from 'stimulus_reflex'
import consumer from '../channels/consumer'
import controller from './application_controller'
const application = Application.start()
const context = require.context('controllers', true, /_controller\.js$/)
application.load(definitionsFromContext(context))
StimulusReflex.initialize(application, { consumer, controller, debug: true })
// Load all the controllers within this directory and all subdirectories.
// Controller files must be named *_controller.js.
import { Application } from 'stimulus'
import { definitionsFromContext } from 'stimulus/webpack-helpers'
import StimulusReflex from 'stimulus_reflex'
import consumer from '../channels/consumer'
import controller from '../controllers/application_controller'
const app = require.context('controllers', true, /_controller\.js$/)
const application = Application.start()
application.load(definitionsFromContext(app))
application.consumer = consumer
StimulusReflex.initialize(application, {
controller,
debug: true,
isolate: true
})
// Load all the controllers within this directory and all subdirectories.
// Controller files must be named *_controller.js.
import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"
const application = Application.start()
const context = require.context("controllers", true, /_controller\.[jt]s$/)
application.load(definitionsFromContext(context))
// Load all the controllers within this directory and all subdirectories.
// Controller files must be named *_controller.js.
import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"
const application = Application.start()
const context = require.context("controllers", true, /_controller\.js$/)
application.load(definitionsFromContext(context))
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb
var Turbolinks = require("turbolinks")
Turbolinks.start()
require("@rails/ujs").start()
import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"
const application = Application.start()
const context = require.context("controllers", true, /.js$/)
application.load(definitionsFromContext(context))
/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb
import { Application } from 'stimulus'
import { definitionsFromContext } from 'stimulus/webpack-helpers'
const application = Application.start()
const context = require.context('../controllers', true, /\.js$/)
application.load(definitionsFromContext(context))
import 'bootstrap';
import Turbolinks from "turbolinks";
import { Application } from "stimulus"
import IndexController from "./controllers/index_controller"
const application = Application.start()
application.register("index", IndexController)
Turbolinks.start();
async function registerController(element, controllerType) {
const stimulusApp = Application.start()
stimulusApp.register(element, controllerType)
return new Promise((resolve) =>
setTimeout(() => {
resolve(stimulusApp.controllers[0])
})
)
}
import "bootstrap"
import Rails from "rails-ujs"
Rails.start()
import * as ActiveStorage from "activestorage"
ActiveStorage.start()
import Turbolinks from "turbolinks"
Turbolinks.start()
import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"
const application = Application.start()
const context = require.context("./controllers", true, /\.js$/)
application.load(definitionsFromContext(context))
import "./cable"
import "./local_time"