Showing posts with label JQuery. Show all posts
Showing posts with label JQuery. Show all posts

February 17, 2012

Hide part of link in global navigation breadcrumb

Hi Friends,

Here the user requirement is to hide top level site URL(link) in the global Navigation breadcrumb in the sub site home page (where user is going to share the site URL with others), and not to hide entire breadcrumb.

Actual snap:
so i proceed to check with the IE Developper tool. and the structure in side DIV for the breadcrumb is as:
<SPAN id="ct100someblablablaID".... >
       <span>
          <a class="anchorclass">ROOT SITE COLLECTION</a>
       </span>
       <span>
          TEXT (>)
       </span>
       <span>
          <a class="anchorclass">SUB SITE COLLECTION</a>
       </span>
       <span>
          TEXT (>)
       </span>
and so on.

so decided to go with JQuery SLECTORS. and the respected script as follows:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {

$('#ctl00_PlaceHolderGlobalNavigation_PlaceHolderGlobalNavigationSiteMap_GlobalNavigationSiteMap span:nth-child(4)').css({'display':'none'});
$('#ctl00_PlaceHolderGlobalNavigation_PlaceHolderGlobalNavigationSiteMap_GlobalNavigationSiteMap span:nth-child(5)').css({'display':'none'});

});
</script>


so in the script selecting sub span elements with in root element SPAN ID,
$('#ROOT_ELEMENT_ID span:nth-child(4)').css({'display':'none'});
this hides my ">" char & selection child node 5 hides my "ROOT SITE URL".

and resulted O/P :

JQuery saved my life....

Regards,
JK

March 31, 2011

Hide "SAVE" button from SharePoint survey

This is another requirement came from user:
His intesion is to hide "SAVE" button from the survey, when it is having link from one question to another.
here the problem is if a survey contails sutch linking pages from question to question, it show "NEXT" "SAVE" "CANCEL" buttos. if user clicks "SAVE" buttot at first question itself the survey end's and the survey comes under incompleted list. which is not expecting the functionality; so by using jquery we can hide the "SAVE" button.

1) Firstofall go to your survey page by clicking "Respond to Survey".
now in the URL after NewForm.aspx add ?PageView=Shared&ToolPaneView=2
like: http://xxxxxxx/xxxxx/NewForm.aspx?PageView=Shared&ToolPaneView=2  , now it will convert the page into edit mode.

2)Now add a content editor web part and copy the below two sections of the scripts in to content editor web part and exit from edit mode, and see the magic :) "SAVE" button will be hidden.
==================================================
//section 1
<script type="text/javascript">
 if(typeof jQuery=='undefined'){
  var jQPath = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3/';
  document.write('<script src="',jQPath,'jquery.min.js" type="text/javascript"><\/script>');
 }
</script>

//section 2
<script type="text/javascript">
$(function() {
 $(":inputs[value='Save']").hide();
  });
</script>
==================================================
so what section 1 will do?
first it will check whether the jquery library included in page or not [it is very important to include jquery library as we are using jquery to hide the button]

what section 2 will do?
it will find Save button and hide it.

thats it...... :)