You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2010/03/29 12:34:28 UTC

svn commit: r928689 - /myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Author: bommel
Date: Mon Mar 29 10:34:28 2010
New Revision: 928689

URL: http://svn.apache.org/viewvc?rev=928689&view=rev
Log:
(TOBAGO-865) simplify ajax

Modified:
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=928689&r1=928688&r2=928689&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Mon Mar 29 10:34:28 2010
@@ -1693,6 +1693,18 @@ var Tobago = {
     return this.browser;
   },
 
+  replaceElement: function(item, newTag) {
+    if (typeof window.Range != 'undefined' && typeof Range.prototype.createContextualFragment == 'function') {
+      var range = document.createRange();
+      range.setStartBefore(item);
+      var fragment = range.createContextualFragment(newTag);
+      item.parentNode.replaceChild(fragment, item);
+    } else {
+      item.insertAdjacentHTML('beforeBegin', newTag);
+      item.parentNode.removeChild(item);
+    }
+  },
+
   parsePartialIds: function(ajaxComponentIds) {
     return ajaxComponentIds.split(",");
   },
@@ -1858,7 +1870,7 @@ Tobago.Panel.prototype.setup = function(
 Tobago.Panel.prototype.doUpdate = function(data) {
   //LOG.debug("Panel reloaded : " + transport.responseText.substr(0,20));
   if (data.responseCode == Tobago.Updater.CODE_SUCCESS) {
-    Tobago.element(this.id).innerHTML = data.html;
+    Tobago.replaceElement(Tobago.element(this.id), data.html);
     try {
       var updateScript;
       eval("updateScript = " + data.script);