JavaScript Removing Groups within an Array in Kineticjs

I am trying to remove elements of an array which contains either Groups(containing shapes) or simply Shapes(line, Rect, Circle etc) as its elements. My function is something like below:

deleteSelectedShape = function () {
var i,
    shapeObj,
    selectedObjects = currentContext.getSelectedObjects(),
    shapeLayer = currentContext.getShapeLayer();

   if (selectedObjects && selectedObjects.length > 0) {
    for (i = 0; i < selectedObjects.length; i += 1) {
        shapeObj = selectedObjects[i];
        // shapeObj.remove(); results same error as mentioned at last

             if (shapeObj.nodeType === "Group") {
                    shapeObj.destroyChildren();
             }
              else{
                 shapeObj.destroy();
               }
            }
        }

         selectedObjects = [];
         shapeLayer.draw();
   };

I tried this also

  if (shapeObj.nodeType === "Group") {
            var childs = [];
            childs = shapeObj.getChildren();
            for (var j = 0; j < childs.length; j++) {
                childs[j].remove();
            }
        }
        else{
             shapeObj.remove();
           }
        }  
    }

Here Individual shapes are getting deleted but if there is group in array, it is giving error :

    TypeError: this.getParent(...) is undefined in Kineticjs file

Please suggest me proper idea. Thank you !!!

Answer:1

I'm assuming I'm doing something really dumb here. I basically have an array that I'm passing into a function. I want to remove an element of that array and do a bunch of stuff to it, and then iterate ...

I'm assuming I'm doing something really dumb here. I basically have an array that I'm passing into a function. I want to remove an element of that array and do a bunch of stuff to it, and then iterate ...

  1. using array shift
  2. using memcpy to shift array

I am building a script that calculates the genetics of animals that are bred together. Each animal has a set of genes (e.g. BbEeKk) and the program should calculate all the genetic possibilities of ...

I am building a script that calculates the genetics of animals that are bred together. Each animal has a set of genes (e.g. BbEeKk) and the program should calculate all the genetic possibilities of ...

  1. polynomial equations using linked list
  2. polynomial equations in hindi
  3. polynomial equations by factoring
  4. polynomial equations in factored form
  5. polynomial equations in real life
  6. polynomial equations with the highest exponent of x as 2
  7. polynomial equations in factored form calculator
  8. polynomial equations in tamil
  9. polynomial equations in excel
  10. polynomial equations with answers
  11. polynomial equations in matlab
  12. polynomial equations with real coefficients
  13. polynomial equations with complex roots
  14. polynomial equations in c
  15. polynomial equations by factoring calculator
  16. polynomial equations with fractions
  17. polynomial equations in data structure
  18. polynomial equations with complex solutions
  19. polynomial equations in r
  20. polynomial equations in one variable

I'm really wondering if this is possible. Right now I'm designing a new personal website for myself with HTML5/CSS3, and I found some nice javascripts to execute on my site such as snowing effects ...

I'm really wondering if this is possible. Right now I'm designing a new personal website for myself with HTML5/CSS3, and I found some nice javascripts to execute on my site such as snowing effects ...

How can I change the background/highlight color of the column group in the following fiddle to another color than the light blue that shows by default? I have tried using plotOptions in various ways ...

How can I change the background/highlight color of the column group in the following fiddle to another color than the light blue that shows by default? I have tried using plotOptions in various ways ...

  1. highcharts change highlight color
  2. highcharts change selection color