Hi, What would be the way to go if I need finer-grained control on what draggables are accepted by a certain droppable? I have a directory-tree-like structure, where elements (files, directories) can get dragged to new positions in the tree. File-elements are of different types (images, sound, text). Now, at first it was easy, certain folders would not accept files of certain types (sound folder will not accept images for example). This was easily handled by the 'accept' option in droppables, since I give those image-file-elements the 'image' class. Now, since folders can be dragged too, I need a little more fine- grained control, since the 'sounds' folder should not allow folders that contain images to be dropped on it. Also, on some folders I want to limit the tree-depth, so for example if a folder containing files and a subfolder is dropped somewhere, it's OK, but if the folder has sub-sub-folders, it's not. (total depth can only be 4 for example).
One way I thought of solving this is by using classnames like 'folder_containing_images' or 'folder_with_2_sublevels" on every element, but this would quickly become tedious to do since there are many many combinations. To automate the process, a lot of code would be needed to adjust classnames when the tree-structure changes. It would be much nicer if the 'accept' option would also allow a function as its argument. The function should be passed the draggable, so it can apply the 'business-rules' to return true or false. I checked the dragdrop.js source and it seems I need to overrule Droppables.isAffected(). I also saw there is a onHover callback which I think can be used instead of 'accept' to manually add/remove the hoverclass after checking business-rules, but I think this will not stop people from dropping a not-allowed element anyway (without the visual clues that the hoverclass provides). So my guess is I should wrap isAffected. Am I right? Or does someone have a better way? Thanks, Mathijs --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
