G-Srikanth / dragtable

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

[SUPPORT REQUEST] How init dragtable one more time? #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, many thanks for you script, it's awesome!

I'm adding new tables through Ajax. So I tried to kill dragObj like this:
dragObj = null;

And then tried to relaunch init, like this;
dragtable.init();

Which doesn't generate any error, but my new table isn't sortable.

How can I achieve such a thing?

Help would be appreciated!

Many thanks!
Jérémy

Original issue reported on code.google.com by jeremy.c...@gmail.com on 10 Jul 2008 at 4:23

GoogleCodeExporter commented 9 years ago
Hey Jeremy,

I had the same problem.
What happens the fist time you load it:

 if (arguments.callee.done) return;
  arguments.callee.done = true;
So if argument.callee.done isnt set(this is case when entering the first time), 
it 
continues the script, but first set the above member to true.

Because in the original case, only some div is replaced in the DOM (when using 
AJAX), the other members/params are still there. a re-init of the object is 
being 
blocked by above line.

what you could do is comment out this line (so your dragtable.init(); restarts 
the 
process again, and is able to attach to the headers of the table), or pass a 
param 
to init() when doing a relaunch and then set set the argument.calle.done to 
true; .

so:

 init: function(blSecondHit) {

    // Don't initialize twices
   if(blSecondHit == true){
    if (arguments.callee.done) return;
    arguments.callee.done = true;
   }
    if (_dgtimer) clearInterval(_dgtimer);
    if (!document.createElement || !document.getElementsByTagName) return;
     alert('test4');
    dragtable.dragObj.zIndex = 0;
    dragtable.browser = new dragtable.Browser();
    forEach(document.getElementsByTagName('table'), function(table) {
     alert('hie ziet wel de tables');
      if (table.className.search(/\bdraggable\b/) != -1) {
alert('hij ziet de class Draggable!!!');
        dragtable.makeDraggable(table);
      }
    });
  },

and then use dragtable.init(true);

Original comment by davidsluis1 on 15 Jul 2008 at 2:21

GoogleCodeExporter commented 9 years ago
lol... I had my debug code still in it s: cleaned it up:
init: function(blSecondHit) {

    // Don't initialize twices
   if(blSecondHit == true){
    if (arguments.callee.done) return;
    arguments.callee.done = true;
   }
    if (_dgtimer) clearInterval(_dgtimer);
    if (!document.createElement || !document.getElementsByTagName) return;
    dragtable.dragObj.zIndex = 0;
    dragtable.browser = new dragtable.Browser();
    forEach(document.getElementsByTagName('table'), function(table) {
      if (table.className.search(/\bdraggable\b/) != -1) {
        dragtable.makeDraggable(table);
      }
    });
  },

Original comment by davidsluis1 on 17 Jul 2008 at 7:59

GoogleCodeExporter commented 9 years ago
The easiest way is:

dragtable.makeDraggable(table)

e.g.

var table = document.createElement("table");
...
dragtable.makeDraggable(table);

I've added a new example file in revision 13 that demonstrates this.

Original comment by danvdk on 30 Jun 2009 at 8:49

GoogleCodeExporter commented 9 years ago
Hello!
I'm adding new rows in draggable tables through Ajax. 
So I tried to kill dragObj and reinit this without success.
My new rows in tables isn't draggable.
How can I solve it?
Help please!
Many thanks!
GV NN

Original comment by gvnn...@gmail.com on 11 Sep 2009 at 9:12