Comments (13)
I meant transformOnAdd would by a prop of vue.draggable that would be a function taking copied element as entry and returning the element to insert:
function transformOnAdd(copiedElement){
...
return elementToCopyInTheTarget;
}
from vue.draggable.
There is a Vue function named Vue.$forceUpdate() which forces vDOM to update.
What you need to do is only writethis.$forceUpdate();
at the end of the success part of your XHR.
from vue.draggable.
Could you provide the template HTML?
from vue.draggable.
Here is the from
:
<h3>Group fields templates</h3>
<ul class="list-group" id="availableGroups">
<draggable @add="onAdd" @sort="onSort" @update="onUpdate" :clone="cloneGroup" :list="groups" :options="{animation: 150, sort: false, group: {name: 'fields', pull: 'clone', put: false}}">
<available-groups v-for="group in groups" :group="group"></available-groups>
</draggable>
</ul>
And here is the to
:
<div class="panel-body">
<draggable class="list-group field-list" :id="'field-list-' + page.id" :data-page_id="page.id" element="ul" @add="onAdd" @sort="onSort" @update="onUpdate" :list="page.fields" :options="{animation: 150, draggable: '.draggable',group: {name: 'fields',pull: 'clone'}}">
<ha-field v-for="field in page.fields" :page_id="page.id" v-bind:field="field" v-on:delete-field="deleteField(field)" v-on:delete-group-field="deleteGroupField(field, [group, field])" v-on:delete-group="deleteGroup(field)"></ha-field>
</draggable>
</div>
And here are the field
component template:
<li class="list-group-item draggable ignore-elements" :id="'field-' + field.id">
<span v-if="field.is_group"><strong>Group: </strong></span>
<span v-else="field.is_group"><strong>Field: </strong></span>
<span class="field-name">@{{field.name}}
<a v-if='field.is_group' :href="'#field-group-list-' + field.id" role="button" data-toggle="collapse" class="btn btn-xs btn-links">
<i class="fa fa-plus"></i></a>
</span>
<p class="pull-right">
<a v-if='!field.is_group' href="#" class="btn btn-xs btn-primary edit-field" :data-field_id="field.id" @click.prevent="editField"><i class="glyphicon glyphicon-pencil"></i></a>
<a v-if='field.is_group' href="#" class="btn btn-xs btn-warning delete-field" :data-field_id="field.id" @click.prevent="$emit('delete-group')"><i class="glyphicon glyphicon-trash"></i></a>
<a v-else='field.is_group' href="#" class="btn btn-xs btn-warning delete-field" :data-field_id="field.id" @click.prevent="$emit('delete-field')"><i class="glyphicon glyphicon-trash"></i></a>
</p>
<ul v-if='field.is_group' class="list-group grouped-fields collapse" :id="'field-group-list-'+field.id">
<li v-for="_field in field.fields" class="list-group-item" :id="'group_field_' + _field.id">
<strong>Field: </strong> @{{ _field.name }}
<p class="pull-right">
<a href="#" class="btn btn-xs btn-primary edit-field" :data-field_id="_field.id" @click.prevent="editField(_field.id)"><i class="glyphicon glyphicon-pencil"></i></a>
<a href="#" class="btn btn-xs btn-warning delete-field" :data-field_id="_field.id" @click.prevent="deleteGroupField(field, _field)"><i class="glyphicon glyphicon-trash"></i></a>
</p>
</li>
</ul>
</li>
Thx
from vue.draggable.
Hi @SebastienDenooz , could you please simplify and create a jsfiddle? Thanks
from vue.draggable.
@SebastienDenooz , Did the fix by @vTrippy work for you?
from vue.draggable.
I am closing this. If needed provided a jsfidle and I will re-open the issue.
from vue.draggable.
Hi all,
So, here is my jsfiddle. I try to simplify a maximum my code : https://jsfiddle.net/jon33s0z/1/
The main question is: How to modify / replace the 'cloned' element in the list where it is droped.
Thank's for your time all!!
Seb
from vue.draggable.
@SebastienDenooz use clone props
from vue.draggable.
Yes i see it, but the clone is fired dirctly on the drag start.
If i have more than one page (more than one target for the drag), the clone is fired on drag start, the xhr is made but i do not know yet what "target" page it is. Assuming the REST ressource is POST /pages/#/fieds/
, on the clone i do not known the page_id.
from vue.draggable.
Well, you can use the add event on the target draggable component or watch the underlying list using vue watch methods.
Another posiibility should be create an "transformOnAdd" prop that on target component will transform the copied element. Thougths?
from vue.draggable.
transformOnAdd would be a good idea!
But i can not 'find' the new element in the event passed to the add to pass it to the transformOnAdd.
I can not find the new vue element. How can find it to passing it to transformOnAdd? That's my problem :s
from vue.draggable.
@SebastienDenooz what is your feedback on this?
from vue.draggable.
Related Issues (20)
- 判断被拖拽元素是否在目标区域内并阻止拖拽
- TypeError: Cannot read properties of undefined (reading 'class')
- Draggable preventing scroll behavior HOT 1
- [feature request] typing for `change` event
- Has this project stopped updating and maintaining
- New draggable under maintenance HOT 1
- Incorrect display of the sheet after dragend HOT 2
- npm i -S vuedraggable 直接报错
- VueDraggable only @choose @unchoose events only getting triggered in vue2.7.15 version
- Please set the `latest` npm tag to v4
- Not working with Socket.io
- How to disable draggable in vue draggable HOT 1
- How to import nested-draggable component ? Vue2
- Triggering drag and drop programmatically
- Missing required prop: "itemKey"
- how to lock vuedraggable for specific array nested level
- Nested Draggable Input with v-model automatically blurs
- Incorrect Visual Representation After Transferring All Items Between Groups
- Address :force-fallback="true" Issue in Cross-List Drag and Drop Cloning with vue-draggable
- 在vue2项目里面 引用vuedraggable ,vue拖拽之后松开就会复原 end事件没有任何发应,start事件可以监听到开始拖拽 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue.draggable.