Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

how to place JS-code to NewForm.aspx of a list in SharePoint 2013 APP.

In sharepoint 2010 we can use this list definition to add JS:

<List ...>
  <MetaData>
    ...
    <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" UseDefaultListFormWebPart="False">
        <WebParts>
          <AllUsersWebPart WebPartZoneID="Main" WebPartOrder="1">
            <![CDATA[ 
            <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"
                xmlns:sfwp="http://schemas.microsoft.com/WebPart/v2/SimpleForm">
              <Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>                         
              <TypeName>Microsoft.SharePoint.WebPartPages.SimpleFormWebPart</TypeName>
              <FrameType>None</FrameType>
              <Title>JS1</Title>
              <sfwp:Content>ANY HTML YOU NEED HERE
              </sfwp:Content>
            </WebPart>
            ]]>
          </AllUsersWebPart>
          <AllUsersWebPart WebPartZoneID="Main" WebPartOrder="2">
            <![CDATA[
            <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
              <Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>                         
              <TypeName>Microsoft.SharePoint.WebPartPages.ListFormWebPart</TypeName>
              <PageType>PAGE_NEWFORM</PageType>
            </WebPart>
            ]]>
          </AllUsersWebPart>
        </WebParts>
      </Form>
    </Forms>
  </MetaData>
</List>

How to do the same for Sharepoint 2013?

share|improve this question
add comment

3 Answers

Check this link out,

How to: Complete basic operations using JavaScript library code in SharePoint 2013

share|improve this answer
    
Can you explain what do you mean? –  user1167761 Sep 7 '12 at 13:49
    
there are no videos –  user1167761 Sep 9 '12 at 10:13
add comment

What exactly are you trying to do with the JS? Is it for a specific column or for the whole form? There are some new things, but it depends on what you are actually trying to do. If it's for a specific column, there's a new JSLink attribute for a that lets you add JS to the column and change how it's rendered in all locations, but that is specific to the column. It would allow you to do something like implement a cascading selection for a column, something quite tricky to do and would only work on a specific form... this new way lets you control it for everything.

share|improve this answer
add comment

From the Ribbon click on List -> Form Web Parts -> Default New Form

enter image description here

Click on Add a Web Part -> Media and Content -> Content Editor

Edit the Content Editor web part and put in the link to the JavaScript file

  • I store the js files at /SiteAssets/js/
  • From a sub-site you can link by using: ../SiteAssets/js/customjs.js
  • Make sure that the js file is formatted using html script tags
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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