Code Monkey home page Code Monkey logo

Comments (4)

caiokawasaki avatar caiokawasaki commented on May 18, 2024 1

@alucidwolf yes! Simple:

<draggable-tree :data="steps" draggable="draggable">
    <div class="step" slot-scope="{data, store}">
        <template>
            <a class="delete-trigger" href="#" @click.prevent="deleteStep(data)">Deletar</a>
        </template>
    </div>
</draggable-tree>

Inside methods:

deleteStep(step) {
    step._vm.store.deleteNode(step)
}

from vue-draggable-nested-tree.

alucidwolf avatar alucidwolf commented on May 18, 2024

@caiokawasaki did you figure this out?

from vue-draggable-nested-tree.

alucidwolf avatar alucidwolf commented on May 18, 2024

@caiokawasaki Sweet! Thank you. I am using a Vuex store to render the data in a computed property, so once I remove the node, I call getPureData() and pass the new tree to a mutation to update the store.

<Tree :data="treeData" draggable="draggable">
  <div slot-scope="{data, store}">
    <div :class="data.children.length > 0 ? 'show-handle' : ''" v-if="!data.isDragPlaceHolder">
      <span @click="test(data, store)" class="icon-trash-alt"></span>
    </div>
  </div>
</Tree>

Method:

test(data, store) {
  store.deleteNode(data);

  let newData = store.getPureData();

  this.$store.commit("nestedDataTest/updateTree", [data]);
}

I am wondering if maybe I do not need to pass store down to the method just to access the getPureData() function on it. Will most likely move these into an action the delete and getPureData() then pass along the final object to a mutation.

Are you familiar with Vuex and have input on that? If not it's OK, you have helped me move forward already. Thanks again!

from vue-draggable-nested-tree.

caiokawasaki avatar caiokawasaki commented on May 18, 2024

@alucidwolf I did not store the tree in the Vuex of my application... Sorry, I do not know how to help you = /

from vue-draggable-nested-tree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.