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

My ascx looks like this:

<SharePoint:ScriptLink ID="ScriptLink1" runat="server" Name="/_layouts/1033/MyProject/js/test.js"/>
test: <input id="example" /> 

test.js looks like this:

$(document).ready(function () {
    alert("test");
});

In MyProject I have a folder called js and in that folder I have test.js

I was under the impression that when I debugged my webpart it would pop up an alert taht said "test" but it does nothing. Am I doing something wrong here?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Do you have a reference to jquery on the page before the test.js include? Try using http://spc3.codeplex.com/wikipage?title=ClientScript&referringTitle=Home

Are there any script errors, is jquery loaded, try testing this before the alert:

if (typeof jQuery == 'undefined') {   
    alert('jQuery not loaded')   
}

Try adding this at the top of your include to make sure the include path is right

alert('test.js loaded')   

Is it a VS2010 project? You need to add one of the sharepoint mapped folders, say LAYOUTS, and make your folder stucture under that (can't start with a folder called js)

MyProject/LAYOUTS/1033/MyProject/js/test.js
share|improve this answer
    
Sorry, I left the jQuery part out. It is in my actual code, just didn't copy it over. I have not added the LAYOUTS folder yet so that is probably the problem. Is it just as simple as creating a folder called LAYOUTS or is there more to it? –  Abe Miessler Apr 11 '11 at 15:15
    
For anyone interested in how to add Mapped Folders see this link: msdn.microsoft.com/en-us/library/ee231521.aspx –  Abe Miessler Apr 12 '11 at 3:00

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.