Tag Info

New answers tagged

0

FYI, If you are only after using (simple) jQuery selectors. Microsoft has this thing called mQuery built in SharePoint. So jQuerys: $('#myID') becomes: m$('myID') straight out of the box, without the need for jQuery It is loaded on most pages (check in F12 developer tools) if not, use: EnsureScriptFunc('mQuery.js', 'm$', function() { // DO STUFF ...


0

Try referencing with this so your listItem inside the methode is always the same: function createListItem() { var clientContext = new SP.ClientContext(siteUrl); var oList = clientContext.get_web().get_lists().getByTitle('Announcements'); var itemCreateInfo = new SP.ListItemCreationInformation(); this.oListItem = ...


0

Please write below mention code outside the For-loop & try it. var ctx = new SP.ClientContext(appweburl); var appCtxSite = new SP.AppContextSite(ctx, hostweburl); var web = appCtxSite.get_web(); //Get the Site var list = web.get_lists().getByTitle("wbslist"); var listCreationInformation = new SP.ListItemCreationInformation(); var oListItem11 = ...


0

When a field is set to required, then Required Field text is added to the title of the field. So, do something like this: function PreSaveAction(){ if($('input[title="FieldName Required Field"]').val() == ''){ alert('Please enter some value'); return false; }else{ return true; } }


1

You can also add your scripts in the following section too. <SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>


2

In your custom page layout first add path to .js file (put path to src="") and then code. <script src="jquery-1.8.3.min.js">//<![CDATA[ //]]> </script> <script>//<![CDATA[ $(document).ready(function(){ //some code }); //]]> </script> <!--MS:<Publishing:EditModePanel ...


0

I was able to get it working. I found the SP.JS file in the Layout folder of Sharepoint. With this I was able to Google about Sharepoint s REST API with OData at https://msdn.microsoft.com/en-us/library/office/fp142385.aspx and about OData Query parameters at http://www.odata.org/documentation/odata-version-2-0/uri-conventions/#SelectSystemQueryOption . This ...


5

I guess you could always use a site collection token in your URL. ~sitecollection URLs and tokens in SharePoint 2013 If that don't work out for you, this blog post has a lot of great examples when working with masterpages and references. Use Site Url in SharePoint Update Try using a scriptlink instead. I'm unsure if encoding is needed thought. Try to ...


0

The following example demonstrates to update SP.FieldChoice field properties: Referred from SHAREPOINT 2013: How can I read Site column contents and modify them via javascript csom function updateFieldChoice(fieldTitle,choiceValues,success,failure) { var ctx = SP.ClientContext.get_current(); var web = ctx.get_web(); var fieldChoice = ...


0

Found a solution myself: Made the field a Lookup field and added the entries the following way: <option value="ItemId">ItemTitle</option> Works perfectly.


0

You got the Minimal Download Strategy feature activated, that's what "ruining" your URL, and it's also why the page Title and the menu is still showing. Head to Site Settings > Site Features and deactivate Minimal Download Strategy. And you could hide the elements using CSS instead. <style type="text/css"> #sideNavBox { display: none; } ...


0

You need to disable the Minimal Download Strategy feature for the script to work right.


0

If you're jQuery file is in a document library, ensure that Team Site Visitors have atleast Read permissions for that document library and also ensure that the jQuery file is checked-in and published (if needed).


0

I see you are using an on-prem version, so I suggest using out-of-the-box ways of achieving this. In the masterpage there should already exist tools to help you achieve this. In SharePoint 2010 (I haven't fooled around with Masterpages in 2013 a lot) the way to solve what you are asking for was to do this: <div name="onetidProjectPropertyTitle"> ...


1

Mark, See if this can help you. If you are writing the custom code this can set you the starting point.


1

It worked! Thank you for your help @Keerthi! For future confused individuals like myself this is what worked: With the jQuery library in the Site Assets library I created a new Script Editor web part with the following snippet: <script src="/SiteAssets/jQuery.1.11.3.min.js" type="text/javascript"></script> **alternatively you can replace the ...


0

You can add a javascript file using the content web part. Edit page -> Add web part -> Media and content -> Content editor -> Add Edit the source of the web part and add the following code into it: ‚Äč<script src="/sites/subsite/list/SiteAssets/file.js" type="text/javascript"></script><script ...


0

ExecuteOrDelayUntilScriptLoaded(init,'sp.js'); function init(){ var cContext = new SP.ClientContext('siteurl'); var oList = cContext.get_web().get_lists().getByTitle('List name'); var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' + '<Value ...


0

function setPublisingHyperlinkValue(fieldInternalName,url,description) { var fieldUrl = $('input[id ^=' + fieldInternalName + '][id $=UrlFieldUrl]'); var fieldDesc = $('input[id ^=' + fieldInternalName + '][id $=UrlFieldDescription]'); fieldUrl.val(url); fieldDesc.val(description); }


1

You mention jQuery, but it can be done without. SharePoint 2013 has its own subset of jQuery called mQuery So a (rather brute) method is to replace all html inside the TH tags with its own label (from the A tag) EnsureScriptFunc('mQuery.js', 'm$', function() { m$('[id^=diidSort]').forEach(function(tag){ if(tag.tagName==='A'){ ...


2

This option is available if you have Publishing enabled on your site, and does not require any JavaScript. Go to Site Settings, find the Navigation link under Look and Feel. Select one of the Structural Navigation options (or if the parent is using Structural Navigation, you can select to use the same as parent). Towards the bottom will be a section ...


1

Each managed property shown in refiner, renders a div with a refinername attribute, which actually defines managed property's html mockup. Below is the sample code: //check the language var language = window.navigator.userLanguage || window.navigator.language; if(language == "en-US"){ //hide/show Managed property's div ...


0

1st answer: This makes the field required and adds asterisk next to the column name. Go to Advanced Settings and Enable the Allow management of content types. Now you will see the content types associated with the list under the Settings section. Click on Item. Select the column. Check the Required radio button. 2nd answer: if(condition){ ...


0

JSLink is usually for displaying content in a different matter. What you may be looking for is to create a custom "NewForm" and "EditForm" using SharePoint Designer. Just open your site in SharePoint Designer, navigate to your list and create two custom forms. One for NewForm, and one for EditForm. Then you can add jquery and javascript logic to make a field ...


1

Create web service using PHP, then call the web service from custom Approval workflow. It means you will need to create copy of the existing Approval workflow so that you can modify it and add step that uses the "Call HTTP Web Service" action. Instructions on using the action can be found here. On SP2010, you can use this CodePlex project to include Web ...


1

I am not sure from the screenshot if you referencing the jQuery file at the correct position. It may lead to not loading of the script. Please try adding a simple script with an alert, if the alert pops up then the position is correct. For the reference error, I am never been able to get CDN working, you can manually store the Jquery file in site assets ...


0

I have implemented something like this for SP2010 using PLUpload. I had to create a custom HTTP Handler (.ashx file) for the server side interaction with SP. Considering you are on SP Online though, server side code is not an option. Maybe you can use the jQuery File Upload API to interact with SharePoint's REST API? For SP Online, that's the approach I ...


1

Either you gotta find ID/title/text of Select All like shown below, and attach click event using jQuery $(".ms-RadioText[title='Select All'] :checkbox").click Here is working example: https://jsfiddle.net/ybyjh1tw/


0

Try putting your custom.js and jquery-1.9.1.min.js at the bottom of the page, so that it loads first. And also why not try loading your function like: $(document).ready(function () { StartCustomFunction(); });


0

I found the answer. The data in the php file was not processed as jsonp because I'm using php 5.1 which doesn't have json_encode function implemented. So I used jsonwrapper: http://www.boutell.com/scripts/jsonwrapper.html Full php example code: require 'jsonwrapper/jsonwrapper.php'; $array = array( '0' => array('fullName' => 'Meni Samet', ...


0

Use jQuery(window).bind instead of using $(window).bind. See jQuery.noConflict(). Could other javascript libraries on your page be using the $ variable? $ is just a variable that is used to alias jQuery and being a variable, anything could be assigned to it.


2

Why do you use Jquery 2 if you want to Support IE8? In the Notes of Jquery 2.x you can find jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8. So: Change to Jquery 1.x if you want to Support IE8


1

A alternate solution is to use CSS instead of jQuery. To change a standard loading spinners in SharePoint 2010 you could implement css to replace the gif with a different one. The old gif will still load but will be displaced and give room for the new spinner. [src*='loadingcirclests16.gif']{ display: block; -moz-box-sizing: border-box; ...


0

The way I've done things like this is int past is to throw all the values into an array, sort it, remove the duplicates, then append it. So something like (untested): function processResult(xData, status) { var optionValues = []; $(xData.responseXML).SPFilterNode("z\\:row").each(function () { ...


0

There is a CheckInFile web service operation. If you are using the SPServices library, there is an operation for that (copied from the documentation): // Check in a single document, disable all of the column controls and give a visual cue that it is checked in function checkInDocument(obj, pageUrl) { var success = true; $().SPServices({ operation: ...


0

Based on the data you are getting back from the call, you'd want to return something like data.split(",")[0].


0

I believe you would need to go through the whole oAuth flow of getting tokens to validate and authorize the user. Matthias has an indepth article on this on his blog, and there is a JS library available to help with the oAuth flow called ADAL.


0

You cannot put server side controls in a CEWP and expect it to work, it won't. The way I've done this in page layouts is to create a hidden div and add all my field references there, each wrapped in their own div or span with a unique ID that I can hook into via jQuery. This then allows me to do what ever I need to do.


0

There are hidden fields that hold the actual value of the fields in the list. In dev tools, $("[id$='MultiLookup']").val() returned the value "2|tTest2|t3|tTest3" for <option value="2" title="Test2">Test2</option> <option value="3" title="Test3">Test3</option> Reference: ...


0

You need to add the selected attribute to the option element: var dest = ('<option selected value="'+fill+'" title="'+dTitle+'">'+dTitle+'</option><option></option>');


0

I think you're missing a $: var dest = $('<option value="'+fill+'" title="'+dTitle+'">'+dTitle+'</option><option></option>'); Why not clone the selected option and then append to the other selects? $(document).ready(function() { ...


0

After doing a lot of research, I found there was one single line missing in my script that immediately made mobile view work exactly as expected. Here is the line I was missing: <meta name="viewport" content="width=device-width", initial-scale="1.0"/>


0

Ok, as requested by the OP, here is a solution for how to deal with MDS when trying to apply CSR. First, a brief explanation of the problem. To quote this blog post (which is where I found the solution of how to do this): When the list view page was first rendered, the MDS system receives the custom javascript for the first time. It then, puts this ...


0

The setTimer function didn't work in the long run, because I couldn't get the PreItemSave action to continue after everything was done. I tried to do a Deferred Object to respond back with a final TRUE value to the PreItemSave at the end of the updates, but I found that it would just continue on after the initial Task creation. My final solution was to use ...


0

This is very simple with jquery var Original_Dispatch= new Date($('#startDate').val()); var Deferral_Raised= new Date($('#endDate').val()); if (Original_Dispatch< Deferral_Raised){ // Do something }


2

I had the same issue and as you said none of the CSS of Script did work for me as well. So I have to patch something with below script. This should be considered as a last option if you have any other solution available. So if you try this, you will have your issue fixed with below script: var interval = null; //Defines the start interval variable ...


0

Are you checking how many options are in #events before you add them (in queryEvents)?


0

Try selecting id using jquery selector For example To get those that end with "ckbxEmp" $(document).on("change", "[id$='ckbxEmp']", function () {


1

Mobile view does not use the same markup, you can test this in your desktop browser by adding Mobile=1 to the URL. A field will look like this: <div class="mb-list-detail-property-panel"> <div class="mb-list-property-name"> UnitId </div><div class="mb-list-property-value"> <input ...


1

If it's Safari on Iphone, then add classic way of getting elements & then hide them like document.getElementById("myDIV").style.display = "none";



Top 50 recent answers are included