Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to namespace docready? #4

Closed
RavenHursT opened this issue May 19, 2015 · 5 comments
Closed

How to namespace docready? #4

RavenHursT opened this issue May 19, 2015 · 5 comments

Comments

@RavenHursT
Copy link

You have this at the top of your library:

// The public function name defaults to window.docReady
    // but you can pass in your own object and own function name and those will be used
    // if you want to put them in a different namespace

But I don't see anything in your documentation as to how to implement this. Can you give some instructions?

@jfriend00
Copy link
Owner

In this line at the very end of the code:

})("docReady", window);

You can pass in your own object and method name and the function will be assigned as that method on that object:

var myNamespace = {};
myNamspace.myMethod = function() {...};

(function(funcName, baseObj) {
....
})("docReady", myNamespace);

Then, you would call docReady like this:

myNamespace.docReady(function() {
   ...
});

@jfriend00
Copy link
Owner

More comments added to the source code to document this issue.

@RavenHursT
Copy link
Author

Ah.. so you'd have to modify the source code to make this happen, I get it now.

Would probably be a good future feature to add an api that allows you to do something like this w/o having to modify the library directly right?

@jfriend00
Copy link
Owner

You can do that yourself already by just putting this code after the docReady code.

myNameSpace.myMethod = docReady;
delete window.docReady;

@RavenHursT
Copy link
Author

Ah... well now that was easy.. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants