Changeset 1575


Ignore:
Timestamp:
2010-06-28 14:05:24 (3 years ago)
Author:
freya
Message:

solves #229 : when deleting child : also clear element index

Location:
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/collection.js

    r1539 r1575  
    246246    CollectionControl.prototype.removeChild = function(childIndex) { 
    247247        var child = this.getChild(childIndex); 
     248         
     249        // element should be removed from element index as well 
     250        this._form.removeElementIndex(child._absoluteId, undefined, true); 
    248251 
    249252        if (child == null) 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/control.js

    r1572 r1575  
    701701      * @param {string} 
    702702      *            [relation] relation-part to remove 
     703      * @param (boolean) 
     704      *            [deleteChildren] set to true if you want all children to be deleted as well 
    703705      */ 
    704      ControlElements.prototype.removeElementIndex = function(index, relation){ 
     706     ControlElements.prototype.removeElementIndex = function(index, relation, deleteChildren){ 
     707         deleteChildren = deleteChildren || false; 
     708          
    705709         if (index == undefined)  
    706710             return; 
    707711 
    708          if(! relation){ 
    709              delete this.elementIndex[index]; 
    710          } 
    711          if(this.elementIndex[index] && this.elementIndex[index].meta[relation]){ 
    712              delete this.elementIndex[index].meta[relation]; 
     712         if(deleteChildren) { 
     713             for(var i in this.elementIndex){ 
     714                 if(i.match("^"+index)==index){ 
     715                     this.removeElementIndex(i, relation, false); 
     716                 } 
     717             } 
     718         }else{ 
     719             if(! relation){ 
     720                 delete this.elementIndex[index]; 
     721             } 
     722             if(this.elementIndex[index] && this.elementIndex[index].meta[relation]){ 
     723                 delete this.elementIndex[index].meta[relation]; 
     724             } 
    713725         } 
    714726     } 
Note: See TracChangeset for help on using the changeset viewer.