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

Dynamic name for dragzone #31

Open
saliljnr opened this issue Sep 4, 2015 · 1 comment
Open

Dynamic name for dragzone #31

saliljnr opened this issue Sep 4, 2015 · 1 comment

Comments

@saliljnr
Copy link

saliljnr commented Sep 4, 2015

Am a newbie to knockout and so maybe this is a thing anyone should know but is there a way to set a dynamic name for dragzone? for instance can I bind dragzone to an observable? It seems one can only have a static name there which limits ko-dragdrop for dynamic use...

@saliljnr
Copy link
Author

saliljnr commented Sep 4, 2015

Well, I figured out where the issue is. I was binding to the id value of an object which was flagged as NOT being a string hence throwing the error "A drag zone must specify a name"... Currently am using this hack.... Maybe not good but works for now.. better suggestions? Is there a way to bind the 'name' option to a function for even more complex dynamic name generation?

var name = options.name; console.log('checking-----------------1' + name); // prints out 1 (initially flagged as not being string) name = String(name); // cast value to string var dragDistance = typeof options.dragDistance === 'number' ? options.dragDistance : 10; dropZones[name] = dropZones[name] || []; eventZones[name] = eventZones[name] || []; if (!name || typeof name !== 'string') { // crisis evaded :8ball: throw new Error('A drag zone must specify a name'); }

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

1 participant