diff options
author | Manolo Carrasco <manolo@apache.org> | 2012-02-13 12:31:39 +0000 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2012-02-13 12:31:39 +0000 |
commit | 41234e95deeba59b8a6ebb48f919fe6d621328ec (patch) | |
tree | 8aec3058ffba530d814d738ed62a0021181f1caf /gwtquery-core/src | |
parent | d1fd135448f1bf548630baba40df7d8582cbba2c (diff) | |
download | gwtquery-41234e95deeba59b8a6ebb48f919fe6d621328ec.tar.gz gwtquery-41234e95deeba59b8a6ebb48f919fe6d621328ec.zip |
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
Diffstat (limited to 'gwtquery-core/src')
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java | 12 |
1 files changed, 10 insertions, 2 deletions
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)</?html[^>]*>\\s*", "") + .replaceFirst("(?si)<head[^>]*>.*</head>\\s*", "") + .replaceFirst("(?si)<script[^>]*>.*</script>\\s*", "") + .replaceAll("<?si></?body[^>]*>\\s*", ""); + // We wrap the results in a div + s = "<div>" + s + "</div>"; + + Ajax.this.empty().append(filter.isEmpty() ? $(s) : $(s).find(filter)); if (onSuccess != null) { onSuccess.setElement(Ajax.this.get(0)); onSuccess.f(); |