1

This is what i am doing with jQuery, jsdom and signalr.js file

//jsdom dependency of jQuery   
var jsdom = require('jsdom').jsdom, document = jsdom('test');  
global.window = document.defaultView;

//below is the suggestion from jQuery developers for work around  
//jquery/jquery#2642 (comment)  
global.XMLHttpRequest = window.XMLHttpRequest;

//jQuery  
var $ = require('jquery');  
$.support.cors = true;

//SignalR added externally    
var signalr = require('./util/jquery.signalR-2.2.0.js');    

This was a working code before i updated node to v4.1.2 and node_module jquery is v2.1.4 and jsdom is v6.5.1. All latest available versions.

After updates i am getting jQuery was not found error where as i was able to see $ was defined already and when it goes to signalr $ is undefined.

Please advice if i need to change anything now with new versions.

Sandy
  • 31
  • 1
  • 5

1 Answers1

0

Try adding the following line before loading the signalR script.

var jQuery = $;

The variable $ may or may not link to jQuery depending on what libraries are being run, the jQuery should always be available. That's why signalR uses the jQuery symbol.

thab
  • 666
  • 1
  • 6
  • 14
  • 1
    This did not worked however jsdom people gave a response and they suggested window.jQuery = $; which did worked. :) https://github.com/tmpvar/jsdom/issues/1262 – Sandy Oct 14 '15 at 01:18
  • Ah busted. I assumed your example was global in which case (on a browser at least), they would have been the same thing. – thab Oct 14 '15 at 09:05
  • I used the following answer to get it working http://stackoverflow.com/questions/36234624/signalr-jquery-and-node/36349657#36349657 – Brendan Apr 04 '16 at 01:06