mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-02 21:24:25 +00:00
Added Stimulus and moved the matstats vanilla js to stimulus controllers. Same with the spectate page.
This commit is contained in:
@@ -7,19 +7,39 @@ import "jquery";
|
||||
import "bootstrap";
|
||||
import "datatables.net";
|
||||
|
||||
// Stimulus setup
|
||||
import { Application } from "@hotwired/stimulus";
|
||||
|
||||
// Initialize Stimulus application
|
||||
const application = Application.start();
|
||||
window.Stimulus = application;
|
||||
|
||||
// Load all controllers from app/assets/javascripts/controllers
|
||||
// Import controllers manually
|
||||
import WrestlerColorController from "controllers/wrestler_color_controller";
|
||||
import MatchScoreController from "controllers/match_score_controller";
|
||||
import MatchDataController from "controllers/match_data_controller";
|
||||
import MatchSpectateController from "controllers/match_spectate_controller";
|
||||
|
||||
// Register controllers
|
||||
application.register("wrestler-color", WrestlerColorController);
|
||||
application.register("match-score", MatchScoreController);
|
||||
application.register("match-data", MatchDataController);
|
||||
application.register("match-spectate", MatchSpectateController);
|
||||
|
||||
// Your existing Action Cable consumer setup
|
||||
(function() {
|
||||
try {
|
||||
window.App || (window.App = {});
|
||||
window.App.cable = createConsumer(); // Use the imported createConsumer
|
||||
console.log('Action Cable Consumer Created via app/javascript/application.js');
|
||||
console.log('Action Cable Consumer Created via app/assets/javascripts/application.js');
|
||||
} catch (e) {
|
||||
console.error('Error creating ActionCable consumer:', e);
|
||||
console.error('ActionCable not loaded or createConsumer failed, App.cable not created.');
|
||||
}
|
||||
}).call(this);
|
||||
|
||||
console.log("Propshaft/Importmap application.js initialized with jQuery, Bootstrap, and DataTables.");
|
||||
console.log("Propshaft/Importmap application.js initialized with jQuery, Bootstrap, Stimulus, and DataTables.");
|
||||
|
||||
// If you have custom JavaScript files in app/javascript/ that were previously
|
||||
// handled by Sprockets `require_tree`, you'll need to import them here explicitly.
|
||||
|
||||
Reference in New Issue
Block a user