Closed GoogleCodeExporter closed 8 years ago
i tested this in the console of http://jsplumb.org:
jsPlumb.removeAllEndpoints("window1");
jsPlumb.repaintEverything();
and i don't see an error. what error are you seeing?
Original comment by simon.po...@gmail.com
on 18 Dec 2012 at 10:47
I think it only causes an error if the element has been removed from the page.
Repro on jsplumb.org:
jsPlumb.removeAllEndpoints("window1");
$('#window1').remove();
jsPlumb.repaintEverything();
TypeError: Cannot read property 'left' of undefined
(jquery.jsPlumb-1.3.16-all.js:593)
repaintEverything tries to draw every key in endpointsByElement, even if there
are no endpoints and the element is gone. Not sure if there is any reason for
it to be looking at elements with no endpoints left.
Maybe more proper place to fix is in deleteEndpoint, since you could remove the
last endpoint that way.
Original comment by next...@gmail.com
on 23 Dec 2012 at 6:33
Here's an evil, terrible hack to work around the issue without changing library
code:
// after deleting endpoints or before calling repaintEverything
var ep = jsPlumb.getTestHarness().endpointsByElement;
for(var k in ep) { if (ep.hasOwnProperty(k) && ep[k].length === 0) delete
ep[k]; }
Original comment by next...@gmail.com
on 23 Dec 2012 at 6:51
I think probably there's a couple of things that need to be done - first the
code should be hardened so as not to fail when drawing from endpointsByElement.
but also jsPlumb should probably have a 'remove' method which takes care of
cleaning up endpoints and then delegates to the underlying library's 'remove'
method.
Original comment by simon.po...@gmail.com
on 23 Dec 2012 at 10:22
so i just took a look at this. removeAllEndpoints was actually expecting a DOM
element or a selector; an ID would not work. I have fixed that, and I've also
added a 'remove' method to jsPlumb.
this will be in 1.4.0.
Original comment by simon.po...@gmail.com
on 24 Dec 2012 at 2:31
Original comment by simon.po...@gmail.com
on 7 Jan 2013 at 8:41
Original issue reported on code.google.com by
786350...@qq.com
on 18 Dec 2012 at 9:16