GithubHelp home page GithubHelp logo

Comments (16)

rniemeyer avatar rniemeyer commented on August 17, 2024

@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.

dealproc avatar dealproc commented on August 17, 2024

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.

rniemeyer avatar rniemeyer commented on August 17, 2024

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.

rniemeyer avatar rniemeyer commented on August 17, 2024

OK- I do see it getting called twice when you set arg.cancelDrop to true. I'll look into that part.

from knockout-sortable.

rniemeyer avatar rniemeyer commented on August 17, 2024

I added a fix for the callbacks getting called twice. Let me know if you see further issues.

from knockout-sortable.

dealproc avatar dealproc commented on August 17, 2024

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.

rniemeyer avatar rniemeyer commented on August 17, 2024

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.

dealproc avatar dealproc commented on August 17, 2024

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.

rniemeyer avatar rniemeyer commented on August 17, 2024

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.

dealproc avatar dealproc commented on August 17, 2024

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.

rniemeyer avatar rniemeyer commented on August 17, 2024

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.

dealproc avatar dealproc commented on August 17, 2024

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.

dealproc avatar dealproc commented on August 17, 2024

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.

rniemeyer avatar rniemeyer commented on August 17, 2024

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.

dealproc avatar dealproc commented on August 17, 2024

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.

rniemeyer avatar rniemeyer commented on August 17, 2024

@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)

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.