Git Product home page Git Product logo

Comments (4)

AaronWatters avatar AaronWatters commented on August 22, 2024

I got it working with some effort. I think you need to use require
to load ace

ace_test = jp_proxy_widget.JSProxyWidget()

def load_test():
    ace_test.js_init("""
        element.requirejs.config({
          paths: {
              d3: '//cdnjs.cloudflare.com/ajax/libs/d3/3.4.8/d3.min',
              ace: '//cdnjs.cloudflare.com/ajax/libs/ace/1.4.7/ace'
          }
        });
        element.requirejs(["ace"], function() { // no argument to load function!
            element.html("ace is loaded: " + ace)
            var e = $('<div id="editor"></div>').appendTo(element);
            e.width("500px");
            e.height("300px");
            var editor = ace.edit(e[0]);
        });
    """)
# You need to wrap the function in "uses_require" to make sure
# require is loaded properly
ace_test.uses_require(load_test)
ace_test

image

from jp_proxy_widget.

psychemedia avatar psychemedia commented on August 22, 2024

from jp_proxy_widget.

AaronWatters avatar AaronWatters commented on August 22, 2024

Actually, I got sporadic failures with the method given above.

This seems to work consistently in my tests:

ace_test = jp_proxy_widget.JSProxyWidget()

def load_test():
    ace_test.js_init("""
        // load ace from a CDN using require.js
        element.requirejs.config({
          paths: {
              //d3: '//cdnjs.cloudflare.com/ajax/libs/d3/3.4.8/d3.min',
              ace: '//pagecdn.io/lib/ace/1.4.8'
          }
        });
        // Use require.js to attach ace to the window object.
        element.requirejs(["ace/ace"], function(ace) {  // no argument to load function!
            element.html("ace is loaded: " + ace)
            var e = $('<div id="editor"></div>').appendTo(element);
            e.width("500px");
            e.height("300px");
            var editor = ace.edit(e[0]);
        });
    """)

# wrap the load operation in 'uses_require' to initialize require.js.
ace_test.uses_require(load_test)
ace_test

from jp_proxy_widget.

psychemedia avatar psychemedia commented on August 22, 2024

Thanks... one thing I notice if I run this is that I get the Uninitialized Proxy Widget warning as if things were loaded twice?

from jp_proxy_widget.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.