-
-
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
get elements from board as JSON #64
Comments
This is nice. I had to keep jKanban data in a var to save on database. Having a function to export kanban to json will make that simpler. |
Can I look into it? |
For sure. Pull requests are always welcome. |
This is very tricky. We have two approaches according to my knowledge. I would like to vote which you guys think it's better. |
i think approach 1. could have some potential inconsistency when the user could be frantically draging the boxes here and there. therefore i consider approach 2 more trustworthy. this could help methods: {
renderJSON(){
const obj = this.$refs.demo2
let boards = []
obj.querySelectorAll('.kanban-board').forEach(el => {
let items = []
el.querySelectorAll('.kanban-item').forEach(i => {
items.push({
title: i.innerHTML,
})
})
boards.push({
id: el.getAttribute('data-id'),
title: el.querySelector('.kanban-title-board').innerHTML,
items,
})
})
return boards
}
}, |
I think this needs to be updated to return the name of the item not the HTML methods: {
renderJSON(){
const obj = this.$refs.demo2
let boards = []
obj.querySelectorAll('.kanban-board').forEach(el => {
let items = []
el.querySelectorAll('.kanban-item').forEach(i => {
items.push({
title: i.childNodes[1].innerHTML,
})
})
boards.push({
id: el.getAttribute('data-id'),
title: el.querySelector('.kanban-title-board').innerHTML,
items,
})
})
return boards
}
}, |
I hope it helps, with this I rather get the id's since with that I can get everything else from the database function renderJSON() {
const obj = document.querySelector('#div_jkanban_id'); // EDIT YOUR DIV ID
let boards = [];
obj.querySelectorAll('.kanban-board').forEach(el => {
let items = [];
el.querySelectorAll('.kanban-item').forEach(i => {
items.push({
element_id: i.getAttribute('data-eid'),
})
})
boards.push({
board_id: el.getAttribute('data-id'),
items,
})
})
return JSON.stringify(boards);
} |
It would be nice to have a function to export the elements to JSON.
Using this it should be easier to send the elements to ajax for example.
The text was updated successfully, but these errors were encountered: