-
-
Notifications
You must be signed in to change notification settings - Fork 877
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 do I use ajv in Dojo? #234
Comments
Have you tried using the bundle from cdnjs? https://github.com/epoberezkin/ajv#using-in-browser |
I did try that as well, but the code did not work. The new Ajv object that is created in that code example is not recognized. (seems the script tag I tried adding got interpreted as a script, not as a code snippet - sort of fixed it int he original comment) What happens is it throws error on this line
Regardless I cannot use the cdnjs anyway because my program is required to run offline (no internet access) In Dojo the require might be something like this
|
You can use the bundle in dist folder it's the same. What happens with the code above? |
By the way, given that dojo doesn't recognise the bundle format (although it's universal) you may have global Ajv. |
What do you mean by the last comment? 'global ajv' Do you have a working example on JSFiddle? Here is my attempt with dojo, https://jsfiddle.net/pbq2yjxy/14/ Both fail |
the problem with the fiddle is that it uses dojo that redefines require. And as I said, Ajv is global (that is until you override it in the second fiddle) So just remove the first line in the second fiddle - it works then. |
Please reopen if it didn't work. |
The second fiddle works as you said, but when using in conjunction with Dojo, it is not possible. It just does not work. I do not know if it is even possible to make it work in a project that also uses Dojo. |
Please create a non-working sample. I think fiddle uses Dojo, no? |
It seems like dojo has its own module system that isn't compatible with both commonjs and AMD, but because it redefines global require it breaks the bundle? Not sure how to fix it, maybe bundle has to be built separately... |
In which order do you load bundles (ajv and dojo)? jsfiddle loads dojo before ajv. Did you try changing the order? |
I think you are right, I got it to work by loading the ajv bundle before I load dojo.js. My index.html looks like this.
|
Thank you! I guess it's worth adding some notes in README. |
I would like to use ajv in my Dojo web application, but cannot figure out how to include the ajv module and use it - when i tried to include it from the source code, it complains it could not find compile module
first I tried including this in my index.html
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ajv/4.1.7/ajv.min.js"></script>
but then I don't know what to do after? How to create Ajv object? I tried the same as the getting started example but it does not work.
I also tried downloading the source code and in my dojo config I included the path to ajv in my packages like this
and then in my script I require it like this
But it just error out.
Any ideas how to do this?
The text was updated successfully, but these errors were encountered: