How to use @rails/ujs - 10 common examples

To help you get started, we’ve selected a few @rails/ujs 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 matestack / matestack-docs / app / javascript / packs / application.js View on Github external
// 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.

require("@rails/ujs").start()
require("@rails/activestorage").start()
require("channels")

import 'css/custom-bootstrap'
import 'css/animation'

// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)

import MatestackUiCore from 'matestack-ui-core'
import '../../matestack/components/header'
import '../../matestack/components/toc/toc'
github decidim / decidim / decidim-core / app / packs / src / decidim / confirm.js View on Github external
dialog.confirm(message).then((answer) => {
    const completed = Rails.fire(element, "confirm:complete", [answer]);
    if (answer && completed) {
      // Allow the event to propagate normally and re-dispatch it without
      // the confirm data attribute which the Rails internal method is
      // checking.
      $(element).data("confirm", null);
      $(element).removeAttr("data-confirm");

      // The submit button click events won't do anything if they are
      // dispatched as is. In these cases, just submit the underlying form.
      if (ev.type === "click" &&
        (
          $(element).is('button[type="submit"]') ||
          $(element).is('input[type="submit"]')
        )
      ) {
        $(element).parents("form").submit();
github connorshea / vglist / app / javascript / src / components / library-table.vue View on Github external
onDelete(row) {
      if (window.confirm(`Remove ${row.game.name} from your library?`)) {
        // Post a delete request to the game purchase endpoint to delete the game.
        fetch(row.url, {
          method: 'DELETE',
          headers: {
            'X-CSRF-Token': Rails.csrfToken(),
            Accept: 'application/json'
          },
          credentials: 'same-origin'
        }).then(response => {
          if (response.ok) {
            // Emit a delete event to force the parent library component to
            // refresh.
            this.$emit('delete');
          }
        });
      }
    },
    loadGames() {
github decidim / decidim / decidim_app-design / app / packs / entrypoints / public.js View on Github external
import $ from "jquery"
import "core-js/stable";
import "regenerator-runtime/runtime";

import '../src/evote_check_nota'
import '../src/vizzs/datacharts'

// Images
require.context('../images', true)

// CSS
import './public.scss';

// This needs to be loaded after confirm dialog to bind properly
import Rails from "@rails/ujs"
Rails.start()
github erikdahlstrand / shrine-rails-example / app / javascript / packs / application.js View on Github external
// 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.

require("@rails/ujs").start()
require("turbolinks").start()


// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)

import 'core-js/stable'
import 'regenerator-runtime/runtime'

import 'bootstrap/dist/css/bootstrap'

import { singleFileUpload, multipleFileUpload } from 'fileUpload'
github example42 / hdm / app / javascript / packs / application.js View on Github external
// 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.

require("@rails/ujs").start()
const Turbolinks = require("turbolinks")
Turbolinks.start()
require("@rails/activestorage").start()
require("channels")
import "controllers"

import "@fontsource/open-sans/400.css"
import "@fontsource/open-sans/400-italic.css"
import "@fontsource/open-sans/700.css"

import "bootstrap"
import "../stylesheets/application"

document.addEventListener("turbolinks:load", () => {
  $('[data-toggle="tooltip"]').tooltip()
  $('[data-toggle="popover"]').popover()
github k0kubun / rspec-openapi / spec / rails / app / javascript / packs / application.js View on Github external
// 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.

require("@rails/ujs").start()
require("@rails/activestorage").start()
require("channels")


// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
github jurgen1c / CS-Media / app / javascript / packs / application.js View on Github external
// 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.

require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")


// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
github rubyforgood / voices-of-consent / app / javascript / packs / embed.js View on Github external
require("@rails/ujs").start()

// Code for the contact form component starts here.
import 'embed/behavior'
github kaishuu0123 / rebacklogs / app / javascript / packs / application.js View on Github external
// 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.

require("@rails/ujs").start()
require("@rails/activestorage").start()
require("channels")

import {config, dom, library} from '@fortawesome/fontawesome-svg-core';
import { faPlusCircle } from '@fortawesome/free-solid-svg-icons/faPlusCircle';
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons/faInfoCircle';
import { faInfo } from '@fortawesome/free-solid-svg-icons/faInfo';
import { faCheck } from '@fortawesome/free-solid-svg-icons/faCheck';
import { faBan } from '@fortawesome/free-solid-svg-icons/faBan';
import { faAngleRight } from '@fortawesome/free-solid-svg-icons/faAngleRight';
import { faPen } from '@fortawesome/free-solid-svg-icons/faPen';
import { faDoorOpen } from '@fortawesome/free-solid-svg-icons/faDoorOpen';
import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
import { faTrashAlt } from '@fortawesome/free-solid-svg-icons/faTrashAlt';
import { faComment } from '@fortawesome/free-solid-svg-icons/faComment';
import { faSquare } from '@fortawesome/free-solid-svg-icons/faSquare';