SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    function jnot defined error...but it definately is!

    Hi,

    can anyone spot my problem.....i'm getting an error saying drag.addDroppables is not defined.


    heres the function:

    Code JavaScript:
    dragAndDrop.prototype.addDroppables = function adddroppables(droppableZones) {
        this.alldragslength = droppableZones;
        for(var dropZoneCount = 1; dropZoneCount <= droppableZones; ++ dropZoneCount) {
    	    Droppables.add('droppable' + this.gameCount + '_' + dropZoneCount, { 
    		    accept: 'dragMe', 
    			hoverclass: 'dropallowed', 
    			greedy: 'false',
    			onDrop : (function(obj, dropZoneCount) {
    			     if(this.replacePieces == true) {
    				     var droppedId = dropZoneCount.id;
    					 var existingPiece = $(droppedId).down('.de_small');
    					 if(existingPiece != undefined) {
    					     existingPiece.remove();
    						 this.count = this.count -1;
    					 }
    				 }
    				 this.count ++;
                	 var newCopy = new Element('div', { 
    				     'id' : obj.id, 
    					 'class' : 'de_small' 
    			     }).update(obj.innerHTML);
    				 if($$('#dragGame' + this.gameCount + ' #trashCan')) {
    				     new Draggable(newCopy, { zindex: false });
    				 }
                	 $(dropZoneCount.id).appendChild(newCopy);
                })
            })
    	}
    }


    and heres where i'm calling it:

    Code JavaScript:
    var drag = new dragAndDrop('2');
    drag.addDroppables('3');
    drag.replacePieces(true);
    drag.trashCan(true);

    I've tried just deleting everything out of the function and just putting an alert in there but i still get the error.

    Any ideas?

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    change

    Code javascript:
    dragAndDrop.prototype.addDroppables = function adddroppables(droppableZones) {

    to

    Code javascript:
    dragAndDrop.prototype.addDroppables = function (droppableZones) {


  3. #3
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    No that doesn't work

  4. #4
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have a live sample of the error we can look at?


  5. #5
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Arrrghh no i don't sorry.....i've just found that chaging the function name has sorted it....i don't know why! I'm now having another even more baffling problem!!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •