When I look at the source code of the dojo 1.7 amd dependency list, i see the following:
define(["./_base/kernel", "./has", "./dom", "./on", "./_base/array",
"./_base/lang", "./selector/_loader", "./selector/_loader!default"],
The only use of an exclamation mark I know is for plugins, I haven't seen this "!default" before.
I read this page "https://github.com/amdjs/amdjs-api/wiki/AMD" and googled about it, but I did not find any answer.
Can anybody help me with that!
Thanks
Wolfgang
Update:
Thank you, Ates Goral, for your answer.
Now everything is clear to me.
Then, the irritating thing for me with this special case was, that "./selector/_loader" occurs twice in the above line, one time without parameters and the next time with a parameter. I saw people writing "dojo/domReady!", so I thought it was mandatory to write an exclamation mark for a plugin, even without parameters. Now I have learned that plugins don't need an "!" and I will write "dojo/domReady".
Another Update:
Today I found the following interesting statement (main.js of https://github.com/csnover/dojo-boilerplate):
The “!” after the module name indicates you want to use special plugin functionality; if you were to require just “dojo/domReady”, it would load that module just like any
other module, without any of the special plugin functionality.
I don't know if this statement is correct. It it is correct, then "./selector/_loader" would have some kind of hybrid functionality?
http://livedocs.dojotoolkit.org/loader/amd
When a module identifier passed to require or define contains an "!",
the loader splits the string in two at the exclamation point. The
string to the left of "!" is treated like a normal module ID and is
used as the identifier for the desired plugin; the string to the right
of "!" is passed to the plugin for processing.
In your case, "default" is being passed to the plugin.
Related
So I'm trying out IntelliJ and possibly moving away from Eclipse. I see I can hover over Javascript methods and actually see some info, which is great. But how do I find out more about what is being shown to me? In the pic below, what does the "?" mean? Does 'void' mean there is not a 'return' statement?
Is this JSDoc? This is old legacy code, so I know there is not any commenting above the function to give more info, so I'd like to know what's going on here. Is this just IntelliJ extrapolating the function arguments and creating its own interpretation?
I assume there's a guide or legend out there for this. But after searching around for a while I feel like I don't know the right search term to look for. Any help is appreciated.
EDIT: We don't use TypeScript at all in our current app.
Quick documentation is mostly based on comments in code. In this case the information comes from bundled definition files (In this case, a d.ts file which is a TypeScript type defintion file). For the methods defined in the project or in its dependencies, IDEA shows information from the JSDoc comments attached to functions.
Looks as if the function is defined in a d.ts file, because explicit type declarations are used, so ? indicates optional parameter, and void means that the function is not returning a value.
I'm attempting to audit my code so that I can find out what jQuery functions I use and how many of them I use. The goal is to remove jQuery and alias its functions with native browser implementations to save on page weight.
Simply put I want to match any jQuery function: $("#whatever").methodname(...
I have tried a basic regular expression to find the times where I use a jQuery selector, which looks a bit like this:
grep -r \$\([\"\'].+[\"\']\)\. jscript/*.js
However, this isn't working very well, and I also want it to match against function names and count them up for me. Can you help?
You won't be able to do that with simple regex lookups.
You need a tool that understands JavaScript, like grasp.
With grasp installed, you could do grasp '#$' file.js to find the references to the $ variable.
Is there out any flag in the CoffeeScript compiler to add single-line coffee comments to Javascript output? I read some time ago it would be supported but it turns out this option still remains unavailable.
The easiest option is just to use block comments everywhere. A search/replace across your code base could take care of this in a trivially short time. You would change
# coffeescript one-line comment, not passed through to js
into this
### coffeescript block comment, which IS passed through to js ###
A harder option would be to mod coffeescript itself. For instance, the coffeescript lexer is very well documented, and shows that the logic used to identify block comments. By carefully modifying the lexer, I imagine you could convince it that your single line comments were block comments, which again, are already passed through to js. I haven't tried this, however.
You can do a single line comment by making it plain JS, eg.
`// this will appear in the compiled JS`
Whether you should or not is a separate question :)
I tried to create custom widget for my site. when I loaded page it says:
mixin #0 is not a callable constructor.
clsInfo.cls.prototype is undefined
I can't find any information about clsInfo, so I don't know what is it. maybe the problem that I use dojo from google:
and my own script is located on localhost. so when my dojo on page initializes something goes wrong with my script. I can't find any good info on dojo, maybe I search in wrong places?
please help me to resolve my problem
I ran into this when I was trying to override a dijit.Dialog so I could bind events to controls within it. We've yet to see if the binding part will work, but if you look at the source, this happens when one of the bases passed in as the second argument fails to resolve to an "[Object function]". In my case, I was passing a String in.
dojo.declare takes 3 arguments:
The name of the custom object "class" you're building
An array of base classes, parents to provide functionality (not the string names of those classes)
A hash of functions and declarations
So if I want to override dijit.Dialog, I have to do:
dojo.declare("myDialogType", [dijit.Dialog], {
function1() {/*Code*/},
function2() {/*Code*/}
}
I had ["dijit.Dialog"] as my second argument and that was the problem.
I strongly recommend using Web Inspector or Firebug with uncompressed local copies of the Dojo library rather than the CDN to figure out what's going on and debug these types of problems. Dojo's documentation is extensive but not complete in some areas and some behaviors have to be figured out by looking at what the code expects. That's not intended as a slight to the authors; once you get it going it's a pretty awesome product, and any documentation for volunteer work is appreciated.
Are you sure Dojo is loading? Did you put your code in a dojo.addOnLoad()? When using a CDN you sometimes run into issues with execution times. dojo.addOnLoad() will not only trigger when the DOM is loaded, it gets called when dojo resources have downloaded, such as dijit._Widget.
I've run into this problem when I screw up the order of my requires which makes _WidgetBase not what _WidgetBase really is. Seems like a simple spot to screw up.
After upgrading to jquery 1.4.1 i noticed there was an error anytime i tried calling json.parse. The issue is part of the regex used in json. it uses a $ in the pattern that conflicts with JQuery's $ shortcut.
I don't want to use the non-conflict option with jquery because i have tons of places i'd have to replace the $ with the new corrected shortcut.
Is there a way to wrap a regex pattern in single quotes or something so the pattern string is handled as literally a string?
Broken section in json-2.0.js: (fails on the $)
if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '#').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
.....
}
Thanks
Update:
The problem was not as it appeared and didn't have to do with a $ conflict. From the OP:
The error was bombing on test.replace because the object that was passed in was already deserialized so the method replace was not found. I guess upgrading to JQuery 1.4.1 had some changes in the way the result object is handled on the success event of the $.ajax function.
Are you sure it's failing on the $, and for that reason? Because that's a massive namespacing/parsing failure if so. There's no reason at all the JavaScript engine should be looking for an external symbol there. It's already encapsulated in the way you asked about (by the slashes, which are effectively quotes for a regex). If that were really the problem, it would be every bit as surprising as the interpreter choking on a $ inside a string. I think your problem lies elsewhere.
Here's a page that pulls in jQuery 1.4.1 and json2.js, and it calls JSON.parse(), and it gets no exceptions or errors: http://gutfullofbeer.net/json.html
The error was bombing on test.replace the object that was passed in was already deserialized so the method replace was not found. I guess upgrading to JQuery 1.4.1 had some changes in the way the result object is handled on the success event of the $.ajax function.
This question should be deleted
Apparently this question cannot be deleted with the amount of answers that have been suggested.