Created
February 5, 2020 01:55
-
-
Save staycreativedesign/8dc2b13bb454dae4eecfa7d131e1ccc5 to your computer and use it in GitHub Desktop.
Getting a reference error : (index):96 Uncaught ReferenceError: Rails is not defined the Rails.ajax isn't working?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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('jquery') | |
require("@rails/ujs").start() | |
require("turbolinks").start() | |
require("@rails/activestorage").start() | |
require("channels") | |
require('owl.carousel') | |
require('isotope-layout') | |
require('packs/redactor.min') | |
require('packs/filemanager.min') | |
require('packs/imagemanager.min') | |
global.$ = $ | |
global.jQuery = $ | |
require('jquery-ui') | |
var jQueryBridget = require('jquery-bridget'); | |
var Isotope = require('isotope-layout'); | |
jQueryBridget( 'isotope', Isotope, $ ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { environment } = require('@rails/webpacker') | |
const webpack = require('webpack') | |
environment.plugins.prepend('Provide', | |
new webpack.ProvidePlugin({ | |
$: 'jquery/src/jquery', | |
jQuery: 'jquery/src/jquery', | |
jquery: 'jquery/src/jquery' | |
}) | |
) | |
const aliasConfig = { | |
'jquery': 'jquery/src/jquery', | |
'jquery-ui': 'jquery-ui-dist/jquery-ui.js' | |
}; | |
environment.config.set('resolve.alias', aliasConfig); | |
module.exports = environment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(index):96 Uncaught ReferenceError: Rails is not defined | |
at HTMLTableSectionElement.update ((index):96) | |
at $.<computed>.<computed>._trigger (jquery-ui.js:634) | |
at $.<computed>.<computed>._trigger (jquery-ui.js:15835) | |
at $.<computed>.<computed>._trigger (jquery-ui.js:130) | |
at $.<computed>.<computed>.<anonymous> (jquery-ui.js:15748) | |
at $.<computed>.<computed>._clear (jquery-ui.js:15825) | |
at $.<computed>.<computed>._clear (jquery-ui.js:130) | |
at $.<computed>.<computed>._mouseStop (jquery-ui.js:14993) | |
at $.<computed>.<computed>._mouseStop (jquery-ui.js:130) | |
at $.<computed>.<computed>._mouseUp (jquery-ui.js:9148) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container.admin-page | |
.row | |
.col-sm-12.mt-2.mb-2 | |
= link_to new_admin_slider_path do | |
.btn.btn-xs.btn-success | |
Create Slider | |
.row | |
.col-sm-12 | |
%table.table.table-hover.index | |
%thead | |
%tr | |
%th{:scope => "col"} Slider | |
%th{:scope => "col"} Actions | |
%tbody#document_list{data: {url: sort_admin_sliders_path}} | |
- Slider.order(:position).each do |slider| | |
%tr{id: dom_id(slider)} | |
%td | |
= slider.title | |
%td | |
= link_to edit_admin_slider_path(slider) do | |
.btn.btn-xs.btn-primary | |
Edit | |
= link_to edit_admin_slider_path(slider) do | |
.btn.btn-xs.btn-danger | |
Destroy | |
:javascript | |
$(document).on("turbolinks:load", () => { | |
$("#document_list").sortable({ | |
update: function(e, ui) { | |
Rails.ajax({ | |
url:$(this).data('url'), | |
type: "PATCH", | |
data: $(this).sortable('serialize'), | |
}); | |
} | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment