Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag drop with helper clone and insertInline messes up the dropped array? #305

Open
phuwin1995 opened this issue Dec 7, 2016 · 9 comments

Comments

@phuwin1995
Copy link

phuwin1995 commented Dec 7, 2016

Quick glance: http://g.recordit.co/GOL1YK5LR8.gif
I create a snippet with clone helper and insertInline to sort the items in the "droppable" area.

<div id="edit-calculator">
    <div id="fields">
          <ul>
            <li 
            ng-repeat='fieldType in fieldTypes' 
            data-drag="true" 
            data-jqyoui-options="{revert: 'invalid', helper: 'clone'}" 
            ng-model="fieldTypes" 
            jqyoui-draggable="{index: {{$index}}, animate: true, placeholder: 'keep'}">
            {{fieldType.name}}
            </li>
          </ul>
    </div> 
    <div id="added">
        <ul data-drop="true" ng-model='addedFields' jqyoui-droppable="{multiple:true}">
	    <li 
	    ng-repeat="item in addedFields track by $index" 
	    data-drop="true" 
	    data-drag="true" 
	    ng-model="addedFields" 
	    jqyoui-droppable="{index: {{$index}}}" 
	    jqyoui-draggable="{index: {{$index}}, insertInline: true, direction:'jqyouiDirection'}" 
	    data-jqyoui-options="{revert: 'invalid'}" 
	    data-direction="{{item.jqyouiDirection}}">
		{{item.name}}
	    </li>
            <li class="placeholder" ng-if="addedFields.length== 0">Your field here</li>
        </ul>
    </div>	
</div>

After dropping an item into the droppable area, it messed up the end array (changes them completely). I have no clue what causes this...

@codef0rmer
Copy link
Owner

@phuwin1995 phuwin1995 changed the title Drag drop with helper clone and insertInline mess up the dropped array? Drag drop with helper clone and insertInline messes up the dropped array? Dec 7, 2016
@phuwin1995
Copy link
Author

phuwin1995 commented Dec 7, 2016

@codef0rmer Can you point which are the wrong lines of code?

@codef0rmer
Copy link
Owner

@phuwin AFAIK, your demo is quite similar to the shopping cart demo I shared earlier. Please refer to it because insertInline and other stuff you do not need.

@phuwin1995
Copy link
Author

@codef0rmer I still need the insertInline because I need the end array to be sortable.

@codef0rmer
Copy link
Owner

codef0rmer commented Dec 8, 2016 via email

@phuwin1995
Copy link
Author

phuwin1995 commented Dec 8, 2016

@codef0rmer Maybe there is a misunderstanding.
In the frontpage, it is written insertInline :

Make a list sortable. Same model is mandatory for draggable and droppable.

@phuwin1995
Copy link
Author

@codef0rmer The issue I have at the moment is that after the first item dropped, the later items mess up the end array. Sortable function works well though.

@hunteryxx
Copy link

@codef0rmer Hi there, I also got this similar issue here.

here is the plunker url https://plnkr.co/edit/lTwpnTdLHtlnhTE1EaLm,

function try to achieve: In shopping cart panel, let's say it already has 1.lolcat shirt & 2.cheezeburger shirt, I want to be able to drag buckit shirt directly from the product panel to the cart panel, the result in the cart panel should have 1.lolcat shirt 2.buckit shirt 3.cheezeburger shirt.

As the plunker url showing, once I drag the buckit shirt from product panel and drop onto cheezeburger shirt which already in the cart panel, everything just mess up, it turns out the result showing 1.lolcat shirt 2.buckit shirt 3.buckit shirt

Please help, thanks!

@hunteryxx
Copy link

@phuwin have you solved the issue you got now, seems I got the same issue at the moment.
Please share some light on the road if you've already figured it out, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants