Giter Club home page Giter Club logo

Comments (7)

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024 1

Better to receive directly the data as array from the backend!
I will document the limitation of v-dragable-for and close the issue.

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024

Hello Robin, v-dragable-for diretive works when binding with array but not with objects. In you case you can transform your questiongroups object into an array and it will work:. Here is a workling example: https://jsfiddle.net/dede89/t81zfo98/

from vue.draggable.

rawbknalb avatar rawbknalb commented on July 28, 2024

how do i transform my questiongroups object into an array? i see, it works as an array.
this would help me a lot. thanks already

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024

You can take a look at here: http://stackoverflow.com/questions/6857468/converting-a-js-object-to-an-array

from vue.draggable.

rawbknalb avatar rawbknalb commented on July 28, 2024

thanks. is there a way in vueJS to set data to an array instead of an object? I use

                getQuestiongroups: function(){
                    this.$http.get('admin/osamaker/api/group/get')
                        .then(function (data){
                            this.$set('questiongroups', data.data);

                    })
                    .catch(function (err){
                        console.log(err);
                    });

from vue.draggable.

rawbknalb avatar rawbknalb commented on July 28, 2024

I found a way:
the data comes from a model query through my php controller. with array_values() it is possible to get the object as an array.

    public function getAction(){
        $questiongroups = Questiongroup::query()->related('questions')->get();

        foreach($questiongroups as $questiongroup){
            $questiongroup->questions = array_values($questiongroup->questions);
        }


        return array_values($questiongroups);
    }
                           Questions Json 

                            [
  {
    "id": 77,
    "questiongroup_id": 1,
    "text": "Question 1",
    "question_order": 1,
    "options": [],
    "data": [],
    "created_at": {
      "date": "2016-07-30 09:03:17.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "modified_at": null
  },
  {
    "id": 78,
    "questiongroup_id": 1,
    "text": "Question 2",
    "question_order": 1,
    "options": [],
    "data": [],
    "created_at": {
      "date": "2016-07-30 09:03:21.000000",
      "timezone_type": 3,
      "timezone": "UTC"
    },
    "modified_at": null
  }
]

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024

Documentation updated.

from vue.draggable.

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.