Skip to content

Commit a83bab0

Browse files
committed
Start section about code API
1 parent a08e630 commit a83bab0

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,47 @@ Then, in the body of the skin, use the skin object to request the library:
4545

4646
HTML Skins
4747
---------------
48-
The skin object mentioned above can also be used from HTML skins. It would look something like this:
48+
The skin object mentioned above can also be used from HTML skins. It would
49+
look something like this:
4950

5051
<object codetype="dotnetnuke/server" codebase="JavaScriptLibraryInclude">
5152
<param name="Name" value="jQuery" />
5253
<param name="Version" value="1.9.1" />
5354
</object>
55+
56+
Code
57+
---------------
58+
There is also an API to request JavaScript Libraries from code. This is needed
59+
in skins prior to DNN 7.3 and the introduction of the `JavaScriptLibraryInclude`
60+
skin object, as well as from extension code (though extensions can also make use
61+
of the skin object, if desired). The primary entry point for the API is the
62+
`RequestRegistration` method of the `JavaScript` static class in the
63+
`DotNetNuke.Framework.JavaScriptLibraries` namespace. There are three overloads
64+
to `RequestRegistration`:
65+
66+
JavaScript.RequestRegistration(String libraryName)
67+
JavaScript.RequestRegistration(String libraryName, Version version)
68+
JavaScript.RequestRegistration(String libraryName, Version version, SpecificVersion specificity)
69+
70+
The overload which doesn't specify a version will request the latest version of
71+
the library. In order to avoid your extensions breaking unexpectedly, it's
72+
probably best to always specify a version number. The second overload, which
73+
includes the version number will request that specific version of the library.
74+
If that version isn't installed, it will instead display an error. The third
75+
overload is probably the best to use for most scenarios. It allows you to pass
76+
a value indicating how specific the version is, as a value of the
77+
`SpecificVersion` enum. The possible values are `Latest`, `LatestMajor`,
78+
`LatestMinor`, and `Exact`. `Latest` is the behavior of the overload with one
79+
argument, `Exact` is the behavior of the overload with two arguments, while the
80+
other two values allow you to get behavior that is in between strict and loose.
5481

82+
When requesting that a JavaScript Library is registered, this will ensure that
83+
it, and any of its dependencies, get included on the page.
84+
85+
86+
5587
License
56-
---------------
88+
=================
5789

5890
This code is released under the [MIT license](LICENSE.md).
5991
However, the individual libraries are licensed by their respective owners.

0 commit comments

Comments
 (0)