Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Documentation? Running curl from the browser console. #74

Closed
SimplGy opened this Issue · 4 comments

2 participants

@SimplGy

I think this is not allowed, but it would be great to know that for sure and be able to read a brief explanation of why. Is the console not allowed to add scripts? Does curl not have the same access to executing code in the console?

define([
    'components/lightbox'
],function(lightbox){
    lightbox('hello');
});

This works in an included JS module, but not from the console. Am I doing something wrong trying to run this in Chrome or Firefox's console?

@unscriptable

Hey @SimpleAsCouldBe!

I see two minor issues with your code snippet.

  1. Anonymous modules only work if the loader can figure out the module id from the file name. Just add a module id and it'll work.

  2. The call to lightbox will execute immediately upon module definition. If you want a module that you can call repeatedly, you should have it return a function:

    define('myModule', ['components/lightbox'],function (lightbox){
    return function () {
    lightbox('hello');
    };
    });

Try that. :)

-- John

@unscriptable unscriptable was assigned
@unscriptable

You are right. This needs to be documented. :)

@SimplGy

I was mixed up. I'm doing a single-page app that only bootstraps in once.

I got so used to starting views with a 'define' that I forgot the application actually used 'curl' to kick everything off.

This works just fine against an already-defined curl module:

curl(['components/lightbox'], function(lightbox){
    lightbox('hello');
});

I added a page to the wiki (couldn't figure out how to put it in the right category though). Hope it helps, feel free to edit or delete if it's not what you're looking for.

https://github.com/cujojs/curl/wiki/Using-curl.js-from-a-browser-console

@SimplGy SimplGy closed this
@unscriptable

Wow, thanks Eric! I'm going to add some very minor adjustments and put it on the main page! -- J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.