riktar / jkanban

Vanilla Javascript plugin for manage kanban boards
https://www.riccardotartaglia.it/jkanban/
Apache License 2.0
1.08k stars 300 forks source link

database and jkanban? #87

Closed monica123m closed 4 years ago

monica123m commented 4 years ago

Hi, i'm trying to make jkanban works with php and mysql, but without success. for example, i cannot get the data-eid parameter correctly, or a lot of things aren't in forms [like comments] and so on.

Any idea on how to male it easiest possible ? thank you.

lb- commented 4 years ago

Hey @monica123m - not sure if this helps but here is how I set up a function for dropEl to read the data attributes from the elements.

    /**
    * handler to collect and store the updated changes in our hidden input once an item
    * moves between columns. Note: code is basic and doed not handle errors.
    **/
    function handleDrop(itemElement, toColumnElement, fromColumElement) {
      // get data on the elements
      var key = itemElement.dataset.eid;
      var from = fromColumElement.parentElement.dataset.id;      
      var to = toColumnElement.parentElement.dataset.id;

      var newChanges = { [key]: [from, to]};
      console.log('newChanges', newChanges);
    }

    document.addEventListener('DOMContentLoaded', function() {
      // load the options from server - this is not related to the issue, just a method of getting data
      var options = JSON.parse(document.getElementById('kanban-options').textContent);

      // build the kanban board with supplied options
      // see: https://github.com/riktar/jkanban#var-kanban--new-jkanbanoptions
      var kanban = new jKanban(Object.assign({}, options, {element: '#kanban-mount', dropEl: handleDrop}));

    });