How to use the stimulus.Application.start function in stimulus

To help you get started, we’ve selected a few stimulus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypa / warehouse / warehouse / admin / static / js / warehouse.js View on Github external
// 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));
github hopsoft / stimulus_toolbox / app / javascript / controllers / index.js View on Github external
// 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 })
github leastbad / beast_mode / app / javascript / controllers / index.js View on Github external
// 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
})
github namiwang / fiber-note / app / javascript / controllers / index.js View on Github external
// 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))
github jasl / cybros_core / app / javascript / controllers / index.js View on Github external
// 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))
github cedarcode / webauthn-rails-demo-app / app / javascript / packs / application.js View on Github external
// 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))
github kami-zh / repost / app / javascript / packs / application.js View on Github external
/* 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))
github michael-simons / bootiful-music / knowledge / src / main / assets / javascripts / application.js View on Github external
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();
github adrienpoly / stimulus-flatpickr / spec / helpers.js View on Github external
async function registerController(element, controllerType) {
  const stimulusApp = Application.start()
  stimulusApp.register(element, controllerType)

  return new Promise((resolve) =>
    setTimeout(() => {
      resolve(stimulusApp.controllers[0])
    })
  )
}
github getcampo / campo / app / webpacker / javascripts / application.js View on Github external
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"

stimulus

Stimulus JavaScript framework

MIT
Latest version published 1 year ago

Package Health Score

72 / 100
Full package analysis