From: Manolo Carrasco Date: Mon, 13 Feb 2012 12:31:39 +0000 (+0000) Subject: filters in Ajax.load were not working find because we were using filter() instead... X-Git-Tag: release-1.3.2~117 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=41234e95deeba59b8a6ebb48f919fe6d621328ec;p=gwtquery.git filters in Ajax.load were not working find because we were using filter() instead of find(). Remove some tags from the returned script before creating new elements --- diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java index 86f5c1cd..f280b52b 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java @@ -340,8 +340,16 @@ public class Ajax extends GQuery { s.setData(data); s.setSuccess(new Function() { public void f() { - GQuery d = $(getData()[0].toString()); - Ajax.this.empty().append(filter.isEmpty() ? d : d.filter(filter)); + // We clean up the returned string to smoothly append it to our document + String s = getData()[0].toString().replaceAll("]+>\\s*", "") + .replaceAll("(?si)]*>\\s*", "") + .replaceFirst("(?si)]*>.*\\s*", "") + .replaceFirst("(?si)]*>.*\\s*", "") + .replaceAll("]*>\\s*", ""); + // We wrap the results in a div + s = "
" + s + "
"; + + Ajax.this.empty().append(filter.isEmpty() ? $(s) : $(s).find(filter)); if (onSuccess != null) { onSuccess.setElement(Ajax.this.get(0)); onSuccess.f();