1

I have a basic SharePoint hosted app that only contains a List with a custom new item form. I followed the directions in this tutorial to set my custom form up as the new item form.

http://www.c-sharpcorner.com/article/add-custom-new-edit-display-form-to-list-using-sharepoint-ho/

One of the strange things I am noticing is that I am unable to reference the local jquery script or any custom javascript file in this new custom form. I have attempted a script tag and a SharePoint:ScriptLink Tag I have tried both

<script type="text/javascript" src="../Scripts/jquery-1.9.1.min.js"></script>

and

<SharePoint:ScriptLink name="../Scripts/jquery-1.9.1.min.js" runat="server" ID="jqry" Localizable="false" />

No matter what way I choose to implement jquery it doesn't seem to accept it. I have narrowed the issue down to a path problem because both implementations work when I use the version of jquery offered by google.

//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js

So I am kind of at a loss now. If I can't reference the version of jquery in the app how am I supposed to reference any custom scripts I build?

Am I going about this the wrong way? Can I not reference external scripts from a custom list form? Any help would be greatly appreciated.

  • What's the url of the form? Typically forms are under /lists/list/Forms (maybe I'm thinking of libraries?). So ../Scripts/jquery.js may not be the correct url. Does ~/Scripts/jquery.js work? – wjervis May 10 '17 at 18:55
  • right now everything is setup more or less as visual studio would when you start a new app for sharepoint. The only thing I really did was add the new list under the project and add the new page under the list. I titled the list Form Enabled list so the site relative URL is set to Lists/Form Enabled List. Could the spaces be an issue? My scripts are under the generic script module and run fine on pages under the pages module. The issue only seems to be pages under my list. – Daniel Whittaker May 10 '17 at 19:08
  • I did attempt the fix and when I used ~ instead of .. VS underlined the result indicating it couldn't find the file at that location. So VS is able to locate the file when I use .. but it still won't run any code when I deploy the app for test. Could my development site not be setup correctly? – Daniel Whittaker May 10 '17 at 19:22
  • Visual Studio may not be aware of how the modules are deployed. When you deploy/debug, what's the relative url of the form? Is it Lists/Form Enabled List/Forms/MyCustomForm.aspx? If so, then ../Scripts/jquery.js will be looking in Lists/Form Enabled List/Scripts/jquery.js – wjervis May 11 '17 at 12:15
  • Okay, now its starting to make sense. I assumed I could reference the scripts the same way I saw them referenced on the Default.aspx page in the Pages module. It didn't occur to me that Lists would probably operate different than a module. That was my fault, If i make the path ~Site/Scripts/jquery.js in a Sharepoint script link tag that seems to fix everything. Still having trouble getting a normal script tag to recognize the location but everything working fine now. thanks – Daniel Whittaker May 11 '17 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.