2

I have a site with jQuery referenced in the master page, I want to add new code to add functionality to the site and utilize jQuery. When I use custom action:

<CustomAction ScriptSrc="~SiteCollection/Style library/MyFolder/MyNewJS.js"
                Location="ScriptLink"
                Sequence="12"/>

to add my JS reference, it references my .js file before the jQuery file in the master page, so I keep having the $ is undefined when I use my .js file.

Any idea how to add the JS file after the jQuery file using custom action or to add it to the body of the page?

1

1 Answer 1

1

You can try a workaround for this by referencing the JQuery from the custom script file instead of the master page. Here are the steps:

  1. Remove the JQuery reference from the master page.
  2. Add document.writeln('<script src="PathToJQueryFile" type="text/javascript"></script>'); as the first line in MyNewJS.js file
1
  • Hi Nadeem, I don't have access to the master page, I need to make a solution and give it to some people so they can deploy it on their environment. So I need to have a way to reference my JS in custom action but at the end of the <body> tag, not in the head. Is there a way to do so? Commented Jan 19, 2015 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.