Comments (16)
@dealproc - I believe that your issue may be from the way that you have the callbacks specified in the binding. When the functions are executed, $parent
will not actually be available. You can try using bind
instead to bind the value of this
and then even bind the first argument. It would look something like this: http://jsfiddle.net/rniemeyer/TffKq/
Otherwise, maybe you can use that fiddle to have demonstrate the issue with the JavaScript that was produced by your Script# code.
from knockout-sortable.
I wound up going back and setting it up like you have it in the Student seating scenario, and i think I'll be ok. I have a lot of hacks that I don't like to get it to do what I want (drag from 1 list to another), but it'll work.
My last issue is that the methods for beforeMove are being called twice, once for each list. You don't see it because of the way you're showing the error, but if you do an Alert, even in your code, you'll see that you get the call twice. Is there a better workaround than having to code around and hack things into persuasion?
from knockout-sortable.
I can't seem to get it to consistently call beforeMove
twice, but I did see it a couple of times. I will have to look into that one.
Maybe if you put together a jsFiddle with your basic idea, I could help with some ideas for cleaning it up. If you feel like you are having to hack, then there is potentially a different way to approach it or a shortcoming in the library that could be addressed. There are some alternatives to using "beforeMove" for preventing items from moving into a list like using the connectClass
option.
from knockout-sortable.
OK- I do see it getting called twice when you set arg.cancelDrop
to true. I'll look into that part.
from knockout-sortable.
I added a fix for the callbacks getting called twice. Let me know if you see further issues.
from knockout-sortable.
I'll give it a copy and paste into the project. You'll know in a few.
Did this change in your example for the student table sorting?
How is this going to affect trying to hook up events between to data-binds="..." so that the business logic can be broken into separate methods, instead of having to add extension properties on each collection to make a decision on how to process?
from knockout-sortable.
Yes this should fix the issue with the seating chart as long as it is using the latest build: http://jsfiddle.net/rniemeyer/Uf7D3/. The file seems to be getting cached that the sample linked from the docs is using from the downloads.
I'm not sure about your second question. Maybe you can describe your scenario a bit more, so that I can get a feel for how you can best utilize the current functionality and/or what enhancements might be necessary.
from knockout-sortable.
collections on left hand side of the screen group objects by "department". objects on right hand side of the screen are orders. We want to prevent users from removing items in their orders and putting them back into the wrong departments.
from knockout-sortable.
So, do the orders have a department property that you are able to use to determine the correct department? Something like: http://jsfiddle.net/rniemeyer/Up2CZ/
from knockout-sortable.
How do I go about editing this in fiddler (new tool in my arsenal... never in it before)... but to answer this particular question, yes. what you have is what I'm needing to do for the reverse.
----- Original Message -----
From: "Ryan Niemeyer" [email protected]
To: "rniemeyer/knockout-sortable" [email protected]
Cc: "dealproc" [email protected]
Sent: Thursday, October 4, 2012 2:48:56 PM
Subject: Re: [knockout-sortable] CancelDrop does not seem to be working when assigned via a binding vs. globally. (#26)
So, do the orders have a department property that you are able to use to determine the correct department? Something like: http://jsfiddle.net/rniemeyer/Up2CZ/
—
Reply to this email directly or view it on GitHub .
from knockout-sortable.
You can either just hit "update", which will give you a new URL with a revision # or you can hit "fork" which gives you a new URL that you can build on yourself.
from knockout-sortable.
Think that I have it with this:
http://jsfiddle.net/Up2CZ/3/
The actual logic is far more involved, the the basis is that I wanted the "orders" to have a checker separate from the "departments". I think this'll do the trick.
Really need to learn more on how to use Fiddler... it's a pretty phenomenal tool.
from knockout-sortable.
feeling a bit dumb... what exactly does the "bind" do in this case?
this.checkItem = function(arg) {
arg.cancelDrop = this.name !== arg.item.department;
}.bind(this);
from knockout-sortable.
The .bind(this)
ensures that no matter where this function is called, the value of this
when it is called will be the same as the value of this
when it was created. Otherwise, this
ends up being the element in the event that is being handled.
from knockout-sortable.
Need to create a test project and post.. thought it had to do with the .bind(this); but wound up being an issue of drag & drop between 2 lists and using templates. for some reason, when I reject a drag and drop, then allow another drag & drop, it's removing it from the source observable collection, but the UI is rendering the "moved" item at the bottom of the source collection list.
from knockout-sortable.
@dealproc - yes, if you have a repro in jsFiddle or something, then I would be happy to take a look.
from knockout-sortable.
Related Issues (20)
- observableArray extended with deferred: true removes items from list HOT 2
- Draggable Incorrectly calls template init/update
- Using droppable next to a sortable
- Draggable Droppable Issue
- sortable dissapears after first drop HOT 4
- knockout-sortable not re-rendering when dragging to same index
- Sortable not working with latest jquery HOT 3
- Input and textarea cannot be selected in Firefox 40
- sortable behaviour inconsistent with droppable/draggable
- Confirmation popup before aftermove is executed HOT 1
- Sortable not working after upgrading to knockout 3.5 HOT 10
- anonymous templates will break in next version of knockout HOT 3
- droppable options drop event issue
- Does not work with knockout 3.5.0 HOT 2
- Problem after upgrading ko to 3.5.1 HOT 3
- Nested sortable support
- knockout-sortable drag and drop not working in Windows touch devices
- Get an error after clean data HOT 3
- JS error introduced by v1.2.1 "Fixed draggable and droppable disposal" HOT 1
- disableSelection on sortable
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 knockout-sortable.