-
-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught ReferenceError: global is not defined #200
Comments
Hello Italo, can you share how are you including jKanban to your rails project? |
import { Controller } from "@hotwired/stimulus";
import axios from "axios";
import "jkanban";
import { get, map, sample } from 'lodash-es';
// Connects to data-controller="board"
export default class extends Controller {
HEADERS = { 'ACCEPT': 'application/json' }
BACKGROUND_COLORS = ['bg-blue-700', 'bg-green-700', 'bg-red-700', 'bg-yellow-700', 'bg-indigo-700', 'bg-pink-700', 'bg-purple-500', 'bg-gray-500', 'bg-teal-500', 'bg-orange-500']
connect() {
axios.get(this.element.dataset.apiUrl, {
headers: this.HEADERS
}).then((response) => {
this.buildKanban(this.buildBoards(response.data))
})
}
// buildClassList(classList) {
// if (isNull(classList)) return '';
// return classList.split(' ').join(',')
// }
buildClassList() {
return `text-white, ${sample(this.BACKGROUND_COLORS)}`
}
buildItens(itensData) {
return map(itensData['data'], (item) => {
return {
'id': get(item, 'id'),
'title': get(item, 'attributes.title'),
'class': this.buildClassList()
}
})
}
buildBoards(bordsData) {
return map(bordsData['data'], (board) => {
return {
'id': get(board, 'id'),
'title': get(board, 'attributes.title'),
'class': this.buildClassList(),
'item': this.buildItens(get(board, 'attributes.items'))
}
})
}
buildKanban(boards) {
new jKanban({
element: `#${this.element.id}`,
boards,
itemAddOptions: {
enabled: true,
}
})
}
} |
I fix with this. globalThis.global = globalThis i'm import this file in my application.js, but i dont know if this is best way |
I made a kanban in a CodeIgniter application before. I imported the compiled jkanban.min.js at the page I needed. I don't know how it works on rails, but if it works, it fits. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've trying use jkanban in my rails project, but i have this error.
how to fix this ?
The text was updated successfully, but these errors were encountered: