question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't get options to work

See original GitHub issue

I suppose I’m overlooking something obvious, but I simply can’t get options to work.

I have a vue2 project containing a simple drag and drop which allows reordering items in a list:

<div id="drag-container" v-dragula="items" bag="items">
    <div v-for="(item, index) in item" :key="item.id" class="row">
        <div class="col drag-handle">
          <div class="drag-icon"></div>
        </div>

        ... item contents here ...
    </div>
</div>

Drag and drop works fine, but I want to allow dragging only via specific handle. I can use the moves option of dragula to control that, but I can’t get it working in vue2-dragula. I tried things like:

Vue.$dragula.$service.options('items', {
  moves: function (el, source, handle, sibling) {
    console.log('moves', el);
    return el.classList.contains('drag-handle')
  }
})

and

  beforeMount: function () {
    this.$dragula.$service.options('items', {
      moves: function (el, source, handle, sibling) {
        console.log('moves', el);
        return el.classList.contains('drag-handle')
      }
    })
  },

But the moves function is never invoked. Any idea what I’m overlooking?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kristianmandrupcommented, May 2, 2017

Great to hear! I’ve added it to the new Wiki page with usage examples

Feel free to help improve the library and the docs!

1reaction
josdejongcommented, May 2, 2017

Ok managed to get it working (starting from one of the working examples from the demo app). The name of the service and drake should match with the created service, and the structure of the created service has to be correct.

<div id="drag-container" v-dragula="items" service="itemsService" drake="items">
    <div v-for="(item, index) in item" :key="item.id" class="row">
        <div class="col drag-handle">
          <div class="drag-icon"></div>
        </div>

        ... item contents here ...
    </div>
</div>
  created () {
    this.$dragula.createService({
      name: 'itemsService',
      drakes: {
        items: {
          moves: function (el, source, handle, sibling) {
            return handle.classList.contains('drag-handle')
          }
        }
      },
      options: {}
    })
  },

Thanks for your help Kristian.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Options" option not working - Microsoft Community
I'm using Excel 365. I want to access the "options" feature. When I click "file" then "options", the menu simply disappears and I'm...
Read more >
Options Orders Not Getting Filled? Try These 3 Adjustments
Check out these 3 easy adjustments to help get your options orders filled quickly.
Read more >
WHY WON'T MY OPTIONS ORDER GET FILLED? - YouTube
In today's video, I want to talk about why your options order isn't getting filled. Options trading can be a great way to...
Read more >
How To Avoid Closing Options Below Intrinsic Value
Closing Long Call Positions. Naturally, you can try to place a limit order to sell at $5.70 (or more reasonably, $5.60—leaving a dime...
Read more >
Common Pitfalls for New Options Traders | Charles Schwab
When you first begin trading options, you may realize that you have additional capital to put to work that may have been tied...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found