1

I want to add button to all web parts of my home page instead of add new item link and I've no idea how to create it For additional information I am using share point 2013.

  • what exactly is the goal here? you want to keep functionality of the add item link, or you want to place something else entirely? what should the new button do? – Tiago Duarte Jul 20 '14 at 8:09
  • The main goal is add item link by an image button for example but I want to show this button in header of my web part, beside of my web part name – Milad Jul 20 '14 at 8:36
0

this is a very rough example but I think you get the idea

  • locate the add new item(s)
  • for each one of them, replace the link by an image (or anything else)
  • move the element from the bottom to a parent element
<!-- change add new item markup for all webparts in page and move them around -->
<script type="text/javascript" src="../Style Library/jquery-2.1.1.min.js"></script>
<style type="text/css">
/*hide the second button - I dont want edit*/
.ms-list-addnew a + a{display:none;}
.customAddLink{position:absolute; right:0;}
td.ms-list-addnew{display:none;}
</style>
<script type="text/javascript">
$(document).ready(function(){
    $('.ms-list-addnew > a').each(function(){
        //alert('found a list webpart!');
        //remove the texts
        $(this).parent().contents().filter(function(){ return this.nodeType != 1; }).remove();
        //place an input button inside the anchor
        $(this).html('').prepend('<input type="button" value="click me" />');
        //move the whole anchor near the webpart title
        $(this).appendTo($(this).parents('.ms-webpart-chrome').children('.ms-webpart-chrome-title'));
        //alert($(this).closest('.ms-webpart-chrome-title').html());//.append(this);
        $(this).addClass('customAddLink');
    });
});

</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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