G-Srikanth / dragtable

Automatically exported from code.google.com/p/dragtable
0 stars 0 forks source link

[SUPPORT REQUEST] used on asp .net with ajax #20

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. add a <asp:ScriptManager ID="ScriptManager" runat="server"> tag
2. the dragtable stops working

We're getting an error from IE 7/8 and Firefox
Message: Sys.ArgumentTypeException: Object of type 'Object' cannot be
converted to type 'Array'.
Parameter name: array

We're using dragtable v1.0

Any help would be greatly appreciated, thanks.

Original issue reported on code.google.com by calbu...@gmail.com on 20 Oct 2009 at 4:13

GoogleCodeExporter commented 9 years ago
Hi,
the problem is the difference between Array and NodeList.
Each "document.getElementsByTagName('..')" returns a NodeList instead of an 
Array.
To solve the problem convert the NodeList to an Array by adding the following 
code:
-------------
var ary = [];
for(var i=0, len = object.length; i < len; i++) {
  ary.push(object[i]);
}
object = ary;
-------------
at the end of the file in the globally resolve for forEach enumeration

Here the final result:

var forEach = function(object, block, context) {
  if (object) {
    var resolve = Object; // default
    if (object instanceof Function) {
      // functions have a "length" property
      resolve = Function;
    } else if (object.forEach instanceof Function) {
      // the object implements a custom forEach method so use that
      object.forEach(block, context);
      return;
    } else if (typeof object == "string") {
      // the object is a string
      resolve = String;
    } else if (typeof object.length == "number") {
      // the object is array-like
      resolve = Array;
      var ary = [];
      for(var i=0, len = object.length; i < len; i++) {
        ary.push(object[i]);
      }
      object = ary; 
    }
    resolve.forEach(object, block, context);
  }
}

Original comment by gerd.pir...@gmail.com on 11 Nov 2009 at 2:00

GoogleCodeExporter commented 9 years ago
Hi, thanks so much for you help. That solved my problem. 

Original comment by calbu...@gmail.com on 2 Dec 2009 at 1:34

GoogleCodeExporter commented 9 years ago
Thanks a TON! Wondered about this error for a few days now.. what an easy 
solution :-)

Original comment by Rwilson...@gmail.com on 22 Apr 2011 at 7:55