0

I am in the process of writing my first plugin for jQuery and object oriented programming in general. I am used to javascript and jQuery at this point and always use console.log() when doing debug things as I am now. However this time around I am getting an error the the 'console' portion of console.log() is undeclared and I can't spit any information out. Does anything about my method look strange or look like it would cause this strange error?

$.fn.setup = function(map) {
  var coords;

  map_ref = "map[name='"+ map + "']";
  img_ref = "img[usemap='#" + map + "']";
  $(img_ref + ',' + map_ref).wrapAll('<div class="mapContainer"></div>');
  $('.mapContainer').append('<canvas id="canvMap" class="ctxLight"></canvas>');
  $(img_ref).addClass("imgLight");

  $('.mapContainer').css( {
    "position": "relative",
    "display": "inline-block"
  } );
  $('.imgLight').css( {
    "position": "absolute",   // necessery styling for                                                                                                                                                                                      
    "z-index": "1"            // layering image and canvas                                                                                                                                                                                  
  } );
  $('.ctxLight').css( {       //  Other things Setup needs to do:                                                                                                                                                                           
    "position": "relative",   //      - Add data- to area tags for group referencing                                                                                                                                                        
    "z-index": "2",
    "pointerEvents": "none"
  } );

  ctx = document.getElementById('canvMap').getContext('2d');
  $('#canvMap').attr('width', $(this).width());
  $('#canvMap').attr('height', $(this).height());
  $(this).initMap();                                                                                                                                                                                                                      

  for (i = 0; i < $(map_ref + ' > area').length(); i++) {
    obj[i] = new MapArea(calcDimension($(this)), 1, $(this));
    console.log('testing'); //this is the line in question
  }
};
Mike
  • 632
  • 7
  • 22
  • Possible duplicate of [Google closure variable window/event/console/... is undeclared error](http://stackoverflow.com/questions/10857775/google-closure-variable-window-event-console-is-undeclared-error) – Spilarix Aug 26 '16 at 22:21
  • I don't think it is browser related. I am just writing in emacs and it is giving me the said error. I use Firefox for dev though and nothing is on the console at run time, Chrome is the same story as far as I can tell. I know the setup function is executing based on the html viewer of Firebug – Mike Aug 26 '16 at 22:22
  • I did run into that question but it wasn't very helpful since I am not using any google tools or products for testing/development – Mike Aug 26 '16 at 22:23
  • Emacs doesn't execute Javascript, how is it giving you that error? – Barmar Aug 26 '16 at 22:26
  • In some versions of IE, the `console` object is not defined if you are not running the debugger. – jfriend00 Aug 26 '16 at 22:28
  • I use it to write the JS, it's capable of picking up on small syntactical things. I am executing through Firefox on a private work server. It seemed strange that the color used to be white with no error and I would get console messages while all of a sudden it is orange, spitting that error out and nothing is coming over the console – Mike Aug 26 '16 at 22:30

0 Answers0