Skip to content

Javascript inside custom module #15448

Answered by weirdyang
chybyk asked this question in Q&A
Mar 4, 2024 · 3 comments · 4 replies
Discussion options

You must be logged in to vote

If I understand correctly, you want to register a script and be able to reference the script file in your templates?
Create a class which inherits from IConfigureOptions<ResourceManagementOptions>

    public class ResourceManifest : IConfigureOptions<ResourceManagementOptions>
    {
        private static ResourceManagement.ResourceManifest _manifest;

        static ResourceManifest()
        {
            _manifest = new ResourceManagement.ResourceManifest();

            _manifest
                .DefineScript("custom-script") // this will be the name you reference
                .SetUrl("~/OrchardCore.Custom/Custom/js/activity.js");
        }

        public void Configure(ResourceMa…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@chybyk
Comment options

@hishamco
Comment options

Comment options

You must be logged in to vote
1 reply
@chybyk
Comment options

Answer selected by chybyk
Comment options

You must be logged in to vote
1 reply
@chybyk
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants