ArcBees / gwtquery-droppable-plugin

GwtQuery droppable plugin
MIT License
7 stars 11 forks source link

removing a droppable without calling destroy first is hard to debug #11

Closed biancashouse closed 9 years ago

biancashouse commented 9 years ago

Suppose element el is a droppable. If I do $(el).remove() but forget to precede it with:

$(el).as(Droppable).destroy()

I will find that future drags won't work.

While I realise that Julien's documentation actually tells us to use destroy() before remove(), I think that it would be very helpful to newbies if you were to add a warning to:

gwtquery.plugins.droppable.client.DragAndDropManagerImpl.initialize()

The line

droppableHandler.reset();

is null when a droppable has been removed, and a warning would be really nice; something like:

if (droppableHandler == null) GQuery.console.error("Did you remove a droppable without calling destroy() first ?");

christiangoudreau commented 9 years ago

Nice point, what do you think @jDramaix

(FYI, he's on vacation until next week)

biancashouse commented 9 years ago

Is there an elegant way to make remove() call destroy(), because otherwise it makes it difficult to have a very dynamic dom; e.g. I am moving droppables around the dom, and repopulationg scrollable panels with new droppables, and removing the old ones.

I guess it may be more complicated, because moving an existing droppable to a new parent loses the event handlers also, right ?

BTW - I'm still using a very old version of droppable, 1.0.8, because I never did get 2.0 to compile. Has anyone progressed the draggable and droppable code ? If not, I'll stick with this version.

On Wed, Mar 18, 2015 at 4:49 AM, christiangoudreau <notifications@github.com

wrote:

Nice point, what do you think @jDramaix https://github.com/jDramaix

(FYI, he's on vacation until next week)

— Reply to this email directly or view it on GitHub https://github.com/ArcBees/gwtquery-droppable-plugin/issues/11#issuecomment-82496085 .

Ian White h: +61 2 9948 9739 m: +61 404 950 122 skype (home): biancashouse

christiangoudreau commented 9 years ago

@jDramaix Ping (Now that you're back :D)

jDramaix commented 9 years ago

Is there an elegant way to make remove() call destroy()

Unfortunately, it's not possible

e.g. I am moving droppables around the dom, and repopulationg scrollable panels with new droppables, and removing the old ones.

I guess it may be more complicated, because moving an existing droppable to a new parent loses the event handlers also, right ?

Use detach() method instead of remove(). The detach removes the element from the dom but keep the event handlers and data associated to the element. It's really useful when you removes an element in order to reattach it to the DOM later.

jclariviere commented 9 years ago

BTW - I'm still using a very old version of droppable, 1.0.8, because I never did get 2.0 to compile. Has anyone progressed the draggable and droppable code ? If not, I'll stick with this version.

It should compile since #7. If not please let us know.

biancashouse commented 9 years ago

Although I have this in my pom :

sonatype http://oss.sonatype.org/content/repositories/snapshots true false

and these deps:

com.googlecode.gwtquery gwtquery-project 1.4.4-SNAPSHOT provided com.arcbees.gquery droppable 2.0-SNAPSHOT com.arcbees.gquery draggable 2.0-SNAPSHOT

I keep getting:

Could not find artifact com.googlecode.gwtquery:gwtquery-project:jar:1.4.4-SNAPSHOT in sonatype ( http://oss.sonatype.org/content/repositories/snapshots)

Any idea what I'm doing wrong ?

Using eclipse Eclipse Java EE IDE for Web Developers

Version: Luna Service Release 2 (4.4.2)

Build id: 20150219-0600

On Fri, Mar 27, 2015 at 12:06 AM, jclariviere notifications@github.com wrote:

BTW - I'm still using a very old version of droppable, 1.0.8, because I never did get 2.0 to compile. Has anyone progressed the draggable and droppable code ? If not, I'll stick with this version.

It should compile since #7 https://github.com/ArcBees/gwtquery-droppable-plugin/pull/7. If not please let us know.

— Reply to this email directly or view it on GitHub https://github.com/ArcBees/gwtquery-droppable-plugin/issues/11#issuecomment-86505512 .

Ian White h: +61 2 9948 9739 m: +61 404 950 122 skype (home): biancashouse

biancashouse commented 9 years ago

Downloading: http://oss.sonatype.org/content/repositories/snapshots/com/googlecode/gwtquery/gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1.4.4-SNAPSHOT.jar

Downloading: http://repo.maven.apache.org/maven2/com/googlecode/gwtquery/gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1.4.4-SNAPSHOT.jar

Downloading: http://google-api-client-libraries.appspot.com/mavenrepo/com/googlecode/gwtquery/gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1.4.4-SNAPSHOT.jar

Downloading: http://gwtquery-plugins.googlecode.com/svn/mavenrepo/com/googlecode/gwtquery/gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1.4.4-SNAPSHOT.jar

Downloading: https://raw.github.com/fernandezpablo85/scribe-java/mvn-repo/com/googlecode/gwtquery/gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1.4.4-SNAPSHOT.jar

Downloading: http://repo1.maven.org/maven2/com/googlecode/gwtquery/gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1.4.4-SNAPSHOT.jar

Downloading: http://gwtquery.googlecode.com/svn/mavenrepo/com/googlecode/gwtquery/gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1.4.4-SNAPSHOT.jar

[INFO]

[INFO] BUILD FAILURE

[INFO]

[INFO] Total time: 10.160 s

[INFO] Finished at: 2015-03-27T13:58:59+11:00

[INFO] Final Memory: 11M/246M

[INFO]

[ERROR] Failed to execute goal on project gwt-module: Could not resolve dependencies for project com.bh.gwt.module:gwt-module:jar:4.0: Could not find artifact com.googlecode.gwtquery:gwtquery-project:jar:1.4.4-SNAPSHOT in sonatype (http://oss.sonatype.org/content/repositories/snapshots) -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

On Fri, Mar 27, 2015 at 1:51 PM, Ian White ian@biancashouse.com wrote:

Although I have this in my pom :

sonatype http://oss.sonatype.org/content/repositories/snapshots true false

and these deps:

com.googlecode.gwtquery gwtquery-project 1.4.4-SNAPSHOT provided com.arcbees.gquery droppable 2.0-SNAPSHOT com.arcbees.gquery draggable 2.0-SNAPSHOT

I keep getting:

Could not find artifact com.googlecode.gwtquery:gwtquery-project:jar:1.4.4-SNAPSHOT in sonatype ( http://oss.sonatype.org/content/repositories/snapshots)

Any idea what I'm doing wrong ?

Using eclipse Eclipse Java EE IDE for Web Developers

Version: Luna Service Release 2 (4.4.2)

Build id: 20150219-0600

On Fri, Mar 27, 2015 at 12:06 AM, jclariviere notifications@github.com wrote:

BTW - I'm still using a very old version of droppable, 1.0.8, because I never did get 2.0 to compile. Has anyone progressed the draggable and droppable code ? If not, I'll stick with this version.

It should compile since #7 https://github.com/ArcBees/gwtquery-droppable-plugin/pull/7. If not please let us know.

— Reply to this email directly or view it on GitHub https://github.com/ArcBees/gwtquery-droppable-plugin/issues/11#issuecomment-86505512 .

Ian White h: +61 2 9948 9739 m: +61 404 950 122 skype (home): biancashouse

Ian White h: +61 2 9948 9739 m: +61 404 950 122 skype (home): biancashouse

jDramaix commented 9 years ago

Could you open a new issue for that?

On Fri, Mar 27, 2015, 4:02 AM Bianca Cat notifications@github.com wrote:

Downloading: http://oss.sonatype.org/content/repositories/snapshots/com/googlecode/ gwtquery/gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1. 4.4-SNAPSHOT.jar

Downloading: http://repo.maven.apache.org/maven2/com/googlecode/ gwtquery/gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1. 4.4-SNAPSHOT.jar

Downloading: http://google-api-client-libraries.appspot.com/mavenrepo/com/googlecode/ gwtquery/gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1. 4.4-SNAPSHOT.jar

Downloading: http://gwtquery-plugins.googlecode.com/svn/mavenrepo/ com/googlecode/gwtquery/gwtquery-project/1.4.4- SNAPSHOT/gwtquery-project-1.4.4-SNAPSHOT.jar

Downloading: https://raw.github.com/fernandezpablo85/scribe-java/ mvn-repo/com/googlecode/gwtquery/gwtquery-project/1.4. 4-SNAPSHOT/gwtquery-project-1.4.4-SNAPSHOT.jar

Downloading: http://repo1.maven.org/maven2/com/googlecode/gwtquery/ gwtquery-project/1.4.4-SNAPSHOT/gwtquery-project-1.4.4-SNAPSHOT.jar

Downloading: http://gwtquery.googlecode.com/svn/mavenrepo/com/ googlecode/gwtquery/gwtquery-project/1.4.4-SNAPSHOT/ gwtquery-project-1.4.4-SNAPSHOT.jar

[INFO]

[INFO] BUILD FAILURE

[INFO]

[INFO] Total time: 10.160 s

[INFO] Finished at: 2015-03-27T13:58:59+11:00

[INFO] Final Memory: 11M/246M

[INFO]

[ERROR] Failed to execute goal on project gwt-module: Could not resolve dependencies for project com.bh.gwt.module:gwt-module:jar:4.0: Could not find artifact com.googlecode.gwtquery:gwtquery-project:jar:1.4.4-SNAPSHOT in sonatype (http://oss.sonatype.org/content/repositories/snapshots) -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

On Fri, Mar 27, 2015 at 1:51 PM, Ian White ian@biancashouse.com wrote:

Although I have this in my pom :

sonatype http://oss.sonatype.org/content/repositories/snapshots true false

and these deps:

com.googlecode.gwtquery gwtquery-project 1.4.4-SNAPSHOT provided com.arcbees.gquery droppable 2.0-SNAPSHOT com.arcbees.gquery draggable 2.0-SNAPSHOT

I keep getting:

Could not find artifact com.googlecode.gwtquery:gwtquery-project:jar:1.4.4-SNAPSHOT in sonatype ( http://oss.sonatype.org/content/repositories/snapshots)

Any idea what I'm doing wrong ?

Using eclipse Eclipse Java EE IDE for Web Developers

Version: Luna Service Release 2 (4.4.2)

Build id: 20150219-0600

On Fri, Mar 27, 2015 at 12:06 AM, jclariviere notifications@github.com wrote:

BTW - I'm still using a very old version of droppable, 1.0.8, because I never did get 2.0 to compile. Has anyone progressed the draggable and droppable code ? If not, I'll stick with this version.

It should compile since #7 https://github.com/ArcBees/gwtquery-droppable-plugin/pull/7. If not please let us know.

— Reply to this email directly or view it on GitHub https://github.com/ArcBees/gwtquery-droppable-plugin/ issues/11#issuecomment-86505512 .

Ian White h: +61 2 9948 9739 m: +61 404 950 122 skype (home): biancashouse

Ian White h: +61 2 9948 9739 m: +61 404 950 122 skype (home): biancashouse

Reply to this email directly or view it on GitHub https://github.com/ArcBees/gwtquery-droppable-plugin/issues/11#issuecomment-86797982 .

biancashouse commented 9 years ago

ok, that sounds good. thanks.

I have replaced all my calls to remove() with:

static public void removeAfterDestroying(GQuery qTheEls) {

final String draggableCss = "." + gwtquery.plugins.draggable.client.Draggable.CssClassNames.GWT_DRAGGABLE; final String droppableCss = "." + gwtquery.plugins.droppable.client.Droppable.CssClassNames.GWTQUERY_DROPPABLE; qTheEls.each(new Function() {

public void f(Element e) {

try {

$(e).find(droppableCss).add($(e)).as(Droppable).destroy();

$(e).find(draggableCss).add($(e)).as(Draggable).destroy();

} catch (Exception ex) {

// ignore

}

$(e).remove();

}

});

}

and, of course, I will need to use detach()/attach() whenever I move stuff around using append() etc.

BTW - I did, yesterday, manage to finally build with gquery 1.4.4-SNAPSHOT and 2.0-SNAPSHOT of draggable and droppable.

Many thanks

Ian

On Fri, Mar 27, 2015 at 12:03 AM, Julien Dramaix notifications@github.com wrote:

Is there an elegant way to make remove() call destroy()

Unfortunately, it's not possible

e.g. I am moving droppables around the dom, and repopulationg scrollable panels with new droppables, and removing the old ones.

I guess it may be more complicated, because moving an existing droppable to a new parent loses the event handlers also, right ?

Use detach() method instead of remove(). The detach removes the element from the dom but keep the event handlers and data associated to the element. It's really useful when you removes an element in order to reattach it to the DOM later.

— Reply to this email directly or view it on GitHub https://github.com/ArcBees/gwtquery-droppable-plugin/issues/11#issuecomment-86504973 .

Ian White h: +61 2 9948 9739 m: +61 404 950 122 skype (home): biancashouse