Web scripting language.
26
votes
9answers
7k views
How do I know if the page is in Edit Mode from JavaScript?
Is there a way to find out if a page is in Edit Mode from JavaScript?
I know in on the server-side can be found using SPContext.Current.FormContext.FormMode but I can't find any means of doing it ...
26
votes
6answers
18k views
How do you get the current list item in JavaScript?
There's all kinds of ECMAScript class library examples around but all of the ones I find show how to retrieve all list items (through SP.ClientContent) but how do you get the current list item? I'm ...
13
votes
1answer
1k views
Change Sharepoint language with a link?
Is there a way to get the language-switch control as static link in the pagelayout?
I want my users to switch between German and English with a single click.
Sorry guys, found a solution :D
...
9
votes
4answers
924 views
Why does having `windows.onload` break page editing?
This is related to an earlier question that I posted:
Can't edit page after adding custom web part!
Basically, I have created a web part with some javascript. When I add this web part to a ...
9
votes
1answer
375 views
Detecting browser and replacing web part?
I have a video I want to display on my SharePoint 2010 public facing site and at the moment I am using Silverlight, however, I would like to replace this with flash (youtube actually) if the users are ...
9
votes
3answers
2k views
Grab a specific property bag using ECMA script
I am trying to grab a key/value pair from a specific property bag but can't find any documentation or example code on how to grab a property bag. Currently I can only seem to grab allProperties. Here ...
9
votes
1answer
1k views
Cannot add custom web part to page using the JS OM
I'm trying to add a custom web part (that is one I have written myself) using the new Javascipt OM available with SharePoint 2010. My solution is also running within the Sandbox.
I have it working ...
8
votes
10answers
2k views
Has anyone optimized the front-end (css/javascript files) of a SharePoint site
So it seems to be that Sharepoint's front-end optimization is non-existant. For example, http://dfs.us.dell.com/Pages/DFSHomePage.aspx, according to YSlow, is serving up 14 separate JavaScript files, ...
7
votes
4answers
3k views
How to log off user from SharePoint site, if the user has been inactive for 20 minutes
How to log off the SharePoint site, if the user is has been inactive for for 20 minutes? Do I need to redirect user to logout page? How would I count the idle time?
7
votes
2answers
4k views
SP.UI.ModalDialog.showModalDialog using the html option
http://msdn.microsoft.com/en-us/library/ff410058.aspx says that you can use the option html to display html text in a modal.
I have a string like this;
var html = ...
7
votes
1answer
350 views
JavaScript Client Object Model functionality to get all the non hidden lists of current web and listing them
We have requirement to get all the non hidden lists of current web using JavaScript Client Object Model(JSOM). I have tried the below code but failed to get the desired result.
function ...
7
votes
2answers
743 views
How do you stop scroll position maintained after postback on lists?
I have a list with paging enabled and a page size of 10.
When you scroll to the bottom of the page hit the next button in the list the page redirects to itself with different querystring parameters ...
7
votes
1answer
722 views
Create a Document Library Item base on a ContentType with JavaScript Object Model (JSOM)
I'm trying to create a new item in my Entreprise Wiki Pages Document Library. It's associated with a News Content type. I was able to retrieve the SP.List object (myList), the SP.ContentType object ...
6
votes
2answers
4k views
Programmatically add JS/CSS to pages
I've created a Visual Studio SharePoint 2010 solution with an ASCX that adds some JavaScript files and CSS to the head of each page; this is based on this article. When I deploy the solution, it adds ...
6
votes
1answer
1k views
Context Menus - Send To not working in IE9
I have a document center with a custom master page. The page is designed with IE9/HTML5/CSS3 in mind. In my other question, I worked out how to fix the IM Presence icons by fixing some core ...
6
votes
3answers
4k views
How to get all items in a View using Client Object Model (JavaScript)
To get all the items in a List you use
// Setup context & load web
context = new SP.ClientContext.get_current();
web = context.get_web();
context.load(web);
// Load task list
this.List = ...
6
votes
3answers
3k views
How to get the ID of the list item just inserted using ecmascript
I am stuck at a place where I have to update a list which has a Lookup column. For example I am using this code to update my normal list
var clientContext = SP.ClientContext.get_current();
...
6
votes
1answer
345 views
Get and remove all currently displayed notifications from SP.UI.Notify
I am sending a variety of notifications via
SP.UI.Notify.addNotification("blah", true);
setting the "sticky bit" to true so that the notification stays visible. When I display a second ...
6
votes
4answers
613 views
ExecuteOrDelayUntilScriptLoaded too slow in Firefox and Chrome
I want to use CSOM but waiting around 2 or 3 seconds after page load before I can even do my first query is crazy! See below. Using jQuery dom ready shows a reasonable ready time, but SP.ClientContext ...
6
votes
2answers
1k views
“a is null” error in vanilla SP2010 install
I'm setting up an SP2010 VM for dev testing purposes. Our vanilla install has no other components present and is throwing JS errors in Chrome and Firefox.
In Firefox (v13):
a is null
...
5
votes
3answers
6k views
Get Site Collection full URL using javascript
I want to get the URL for my site collection. One way I thought I could do it was using the window.location in javascript and getting it that way.
I know that you can use ECMA script and the client ...
5
votes
4answers
3k views
Get current web url in a SPRibbon Custom Action Command
I've a SPRibbon custom action with the purpose of open an custom app page in a modal dialog,
but I'm getting troubles for getting the current web URL, as well, set a reference for a .js with the right ...
5
votes
4answers
786 views
How to access a Web application/Farm level property bag via jQuery/Javascript/ClientContext
It it possible to access the Web application/Farm level property bag using jQuery/Javscript/ClientContext? If not, then what are the possible alternatives to access Web Application Farm level property ...
5
votes
2answers
3k views
Get the current UI language with ECMAScript
Is it possible to get the display language from within ECMAScript?
Similar to http://www.sharepointoverflow.com/questions/3129/get-the-current-ui-language-from-a-webpart, I'd like to get the user's ...
5
votes
2answers
652 views
Javascript Client object model, rename folder
Hey am trying to rename a folder inside a Document library, right now i get my item and everything is good but when i try to rename it using set_item('title', 'NewFolderName') it crashes and unwinds ...
5
votes
2answers
3k views
How to disable a ribbon button when a folder is selected
I have added a new button to the SharePoint ribbon for document libraries. This all works well and the button is enabled / disabled depending on the number of items selected... fine!
I want to ...
5
votes
3answers
7k views
How to use JavaScript and CSS in a web part?
I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise. I am using publishing portal template. I am developing using VSTS 2008 + C# + .Net 3.5 + ASP.Net. And I want to ...
5
votes
2answers
822 views
How to retrieve distinct values with JavaScript Client Object Model
How can you get distinct values from a SharePoint List column using JavaScript without a huge performance hit?
A simple example would be appreciated :)
5
votes
2answers
5k views
How can I use the SharePoint Javascript Object Model from a plain HTML page?
I would like to use the SharePoint Javascript Object Model from a "plain" html page (ie, not an .aspx application page etc.) Is this even possible? If so, what scripts should I reference? I've added ...
5
votes
5answers
1k views
Include JavaScript in a feature
I remember seeing somewhere that you can include an external JavaScript file in a SharePoint feature if it is in the _layouts folder. For the life of me I can't remember how to do this!
5
votes
2answers
5k views
Adding ScriptLink for js file to my Visual Webpart causes error: “Cannot make a cache safe URL for…”
Full error:
Cannot make a cache safe URL for
"sprocketcomplete/layouts/sprocketcomplete/js/sprocketcomplete.js",
file not found. Please verify that the
file exists under the layouts
...
5
votes
3answers
2k views
Site Assets vs. Style Library
I usually store my JavaScript/jQuery files in the Site Assets library, but I see on forums that others are using the Style Library.
What are the respective benefits of each?
5
votes
1answer
6k views
the property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested
The below question was based on this article:
http://www.learningsharepoint.com/2011/09/10/get-all-folders-using-ecmascriptjavascript-client-object-model-sharepoint-2010/
I think the author there ...
5
votes
1answer
144 views
What does ULSxSy:; do in SharePoint JS files?
So I was going through init.js and sp.js and found out that nearly all of the SharePoint OOB JS functions start with the following line: "ULSxSy:;"
For example:
function ctxInitItemState(ctxCur)
...
5
votes
1answer
87 views
Check if web is in pagepreview mode - ?pagepreview=true
How can I check if a page is in ?pagepreview=true mode?
I've branded the sharepoint ribbon and need to check if a page is in pagepreview to get the site branded correct (js / css). Is there a way to ...
4
votes
4answers
6k views
Javascript to display sharepoint list items on page load
With Client Object Model API and a bit of javascript, I want to retrieve the items of a sharepoint list and display them into the web page, when the web page loads.
I've successfully implemented ...
4
votes
4answers
2k views
What is the proper way to add jQuery to a MasterPage?
Currently I am using this method in the header:
<script src="/_layouts/MNCAssets/scripts/jquery-1.5.1.min.js"></script>
But for some reason, my webparts that use jQuery don't appear to ...
4
votes
8answers
9k views
Getting a count of list items in a list via ECMAScript
I have a SharePoint 2010 web site with a master page that has a counter on it. I'm trying to update that counter using the ECMAScript. The code I have falls nicely into the success method - but I ...
4
votes
4answers
2k views
Multiple Values in CAML query from Array? SharePoint 2010 using jQuery/SPServices
So if I use SPServices to GetListItems with CAMLQuery, is it possible to insert multiple values inside Value Type='Number'> here
I would like to evaluate things throught a flow in my page, add to an ...
4
votes
6answers
7k views
How do I determine a user's SharePoint group membership using the client object model?
I want to redirect users from a landing page to another page in SharePoint 2010, based on their group membership. I need to do this using JavaScript (ECMAScript) and not server side code.
4
votes
3answers
5k views
Cannot get field value of list item through JavaScript
I try to get the value of a list item (that is currently selected). I know that I must load it into the context but even with loading the field explicitly I get the following message.
Microsoft ...
4
votes
1answer
1k views
how to get users from SharePoint user profile db using jquery
I just want to know, is there any way to get a SharePoint user using javascript / jquery from default SharePoint 2010 user profile db?
My requirement is to form an array of all SharePoint site users ...
4
votes
4answers
7k views
“the HTML source you entered might have been modified”
"the HTML source you entered might have been modified"
In SharePoint 2010, this is the scary message you get everytime you use the "edit HTML source" button with the Content Editor Web Part.
In ...
4
votes
2answers
141 views
how to set list alert using javascript in sharepoint 2010?
I need to set a list alert for current (logged in) user using javascript.
var currentcontext = new SP.ClientContext.get_current();
var currentweb = currentcontext.get_web();
...
4
votes
1answer
3k views
How to get all fields of a list using JS Client Object Model
Is it possible to retrieve all fields of a list (or default view) through the JavaScript Client Object Model and filter the fields on type (e.g. I only want the Choice fields).
var clientContext ...
4
votes
1answer
204 views
Error using javascript to retrieve a SharePoint list's items
I am trying to use this method to query items of a column of a list in my SP site via javascript (the reason I am doing this is to display that info on the page by modifying the html tags in the DOM), ...
4
votes
2answers
748 views
sharepoint 2013 rest api upload image
I want to upload image or create image in Sharepoint 2013 document library using rest api (Javascript)
my code to get bite array from input type file element is
var reader = new FileReader();
...
4
votes
2answers
688 views
SP.SOD how to use correctly?
SP.SOD is a nice feature of SharePoint, but how should I use it? For example, I use these lines of code
ExecuteOrDelayUntilScriptLoaded(function () {
//code
}, "custom.js");
If I understand ...
4
votes
2answers
1k views
How to read a column type SPUser, DateTime, Currency with EcmaScript?
I have a list in SharePoint 2010 with some columns. All are default types. So I have
"Single line of text"
"Multiple line of text"
"Date and Time"
"Choice"
"Number"
"Currency"
"Person or Group"
...
4
votes
2answers
3k views
Get list by Internal Name using ECMAScript / JavaScript Object Model
How can I load items from a list using its InternalName?
As far as I know I can get it using either Id or Title like the following:
var clientContext = new SP.ClientContext('/News/');
var web = ...
