Repository: bokeh/bokeh

Issue:
$ can get overridden in the Notebook 
It is (evidently) possible for other libraries to override `$`, and then our use of `$(function() ...)` as `js_wrapper` here:

https://github.com/bokeh/bokeh/blob/master/bokeh/resources.py#L248

is fragile, and can cause problems, specifically plots not reloading. This was reported here:

https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/7CJxL7cKxXs

@mattpap just changing to `Bokeh.$` seems to work fine. Do you have any other input?

Discussion:

Patch:
diff --git a/bokeh/resources.py b/bokeh/resources.py
index b78021b7a..3fdf39ebf 100644
--- a/bokeh/resources.py
+++ b/bokeh/resources.py
@@ -245,7 +245,7 @@ class Resources(object):
         def pad(text, n=4):
             return "\n".join([ " "*n + line for line in text.split("\n") ])
 
-        wrapper = lambda code: '$(function() {\n%s\n});' % pad(code)
+        wrapper = lambda code: 'Bokeh.$(function() {\n%s\n});' % pad(code)
 
         if self.dev:
             js_wrapper = lambda code: 'require(["jquery", "main"], function($, Bokeh) {\nBokeh.set_log_level("%s");\n%s\n});' % (self.log_level, pad(wrapper(code)))


Test patch:
diff --git a/bokeh/tests/test_resources.py b/bokeh/tests/test_resources.py
index a94b08daf..3d6858293 100644
--- a/bokeh/tests/test_resources.py
+++ b/bokeh/tests/test_resources.py
@@ -5,13 +5,13 @@ from os.path import join
 import bokeh
 import bokeh.resources as resources
 
-WRAPPER = """$(function() {
+WRAPPER = """Bokeh.$(function() {
     foo
 });"""
 
 WRAPPER_DEV = '''require(["jquery", "main"], function($, Bokeh) {
 Bokeh.set_log_level("info");
-    $(function() {
+    Bokeh.$(function() {
         foo
     });
 });'''