FileDrop
FileDrop copied to clipboard
If you create a new FileDrop for a node which is not inserted into the DOM, FileDrop fails to initialize properly
The problem in this case is (in prepareInput()) the line: if (target && global.isTag(global.byID(target), 'iframe')) {
Here global.byID(target) can't find the iframe because the parent DOM is not inserted into the global DOM. It should be like baseNode.findByID(target)
It's not a good idea to initialize FileDrop on a non-inserted zone node because eventually you will insert it into the main document which will remove all previously bound DOM event listeners so you'll need to re-attach them (fd.hook()
and friends). This is not a very standard/intended behaviour.
Why are you initializing FileDrop before inserting its zone node into the document?
I have something like this.
$("#panel").append(renderComponentNode());
where
function renderComponentNode() {
var $node = $("<div></div>");
// ... here much code for creating the contents inside of $node
// ... here FileDrop is inserted also inside of $node
// events are working all right
$node.find("button").click(function () { ... });
return $node;
}
Sorry for the delay. Do you still need a solution? I think I know what can be done although I expected FileDrop to have access to main DOM upon initiaization.
If you're still on it can you confirm that it currently works fine if you disable iframe?
new FileDrop('zone', {input: false})
@ProgerXP I had to redesign my code a little bit to get it working, but still I think that FileDrop should not rely on that it has access to the main DOM. Nobody who is using some kind of a component system will not be able to use FileDrop if it need the main DOM.
(I have to support IE8, so I need iFrame support also)
@igormukhin I get your point. Should this question bother someone else - write up here.